在 Delphi 中创建本地 HTTP 监听器

问题描述 投票:0回答:1

我有一个用 Delphi 11 编写的 Windows 桌面应用程序,我正在将其与 Xero 会计集成。 第一步已完成,即使用 ShellExecute 打开浏览器并生成一个 url,让用户有机会登录。 使用的 url 参数是包含端口的重定向 uri。

如何在 Delphi 11 中创建一个本地 http 监听器来接收 Xero 发回的数据?

delphi listener httpserver delphi-11-alexandria
1个回答
0
投票

创建一个新应用程序,在其上放置一个 TIdHTTPServer 组件(或在代码中创建它),将其 Active 属性设置为 True,并实现其 OnCommandGet 方法,例如如下所示:

procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
  ShowMessage(ARequestInfo.URI);
end;
© www.soinside.com 2019 - 2024. All rights reserved.