通过 Delphi 的 TIdHTTP 访问 Clickbank API?

发布于 2024-11-08 16:21:34 字数 308 浏览 0 评论 0原文

我正在尝试从我的 Delphi 项目访问 ClickBank API,以检查客户是否拥有有效的订阅。

我在此处找到了 API 文档,但有没有德尔福示例。所以我试图创建我自己的小例子,但是我无法用 Indy 的 TIdHTTP 弄清楚它。

谁能指出我正确的方向,也许可以举一个最小的例子?

PS:我尝试查看 C# 示例,但无法将其移植到 Delphi。

I am trying to access the ClickBank API from my Delphi project, to check if a customer has a valid subscription.

I found the API Documentation here, but there are no Delphi examples. So I am trying to create my own little example, however I just cant figure it out with Indy's TIdHTTP.

Could anyone point me in the right direction, perhaps set up a minimal example?

P.S: I tried looking at the C# sample, however I cant port it to Delphi.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖阳 2024-11-15 16:21:34

ClickBank 示例 C# 位于此处 https://sandbox.clickbank.com/api_12_examples/api_example.csharp

HttpWebRequest 请求 = (HttpWebRequest)
    WebRequest.Create("https://api.clickbank.com/rest/1.2/orders/list");
request.Accept = "application/xml";
request.Headers.Add(HttpRequestHeader.Authorization,
        “<<开发者密钥>>:<>”);
请求方法 = "GET";

HttpWebResponse 响应 = (HttpWebResponse) request.GetResponse();

PHP 版本是
https://sandbox.clickbank.com/api_12_examples/api_example.php

您会看到他们在这里没有做太多设置...只是设置两个标头并执行 GET。

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.clickbank.com/rest/1.2/orders/list");
curl_setopt($ch, CURLOPT_HEADER, true); 
curl_setopt($ch, CURLOPT_GET, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "Accept: application/xml",
        "Authorization: << DEVELOPER KEY >>:<< API KEY >>"));
$result = curl_exec($ch);
curl_close($ch);

在 Delphi 中 - 一个快速演示是将 TIdHTTP1 客户端以及按钮和备忘录放在表单上。然后单击按钮(其中 xxx= 您的开发人员密钥,yyy= 您的 api 密钥)执行相同操作 - 设置两个标头并执行 GET:

IdHTTP1.Request.Accept := 'application/xml';
IdHTTP1.Request.CustomHeaders.Add('Authorization: xxx:yyy');
Memo1.Text := IdHTTP1.Get('https://api.clickbank.com/rest/1.2/orders/list');

ClickBank sample C# is found here https://sandbox.clickbank.com/api_12_examples/api_example.csharp

HttpWebRequest request = (HttpWebRequest)
    WebRequest.Create("https://api.clickbank.com/rest/1.2/orders/list");
request.Accept = "application/xml";
request.Headers.Add(HttpRequestHeader.Authorization,
        "<< DEVELOPER KEY >>:<< API KEY >>");
request.Method = "GET";

HttpWebResponse response = (HttpWebResponse) request.GetResponse();

The PHP version is
https://sandbox.clickbank.com/api_12_examples/api_example.php

You'll see that they aren't doing much setup here... just setting two headers and performing a GET.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.clickbank.com/rest/1.2/orders/list");
curl_setopt($ch, CURLOPT_HEADER, true); 
curl_setopt($ch, CURLOPT_GET, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "Accept: application/xml",
        "Authorization: << DEVELOPER KEY >>:<< API KEY >>"));
$result = curl_exec($ch);
curl_close($ch);

In Delphi - a quick demo is to drop a TIdHTTP1 client on a form, along with a Button and a Memo. Then on an onclick of the button (where xxx= your developer key and yyy= your api key) do the same - set two headers and perform a GET:

IdHTTP1.Request.Accept := 'application/xml';
IdHTTP1.Request.CustomHeaders.Add('Authorization: xxx:yyy');
Memo1.Text := IdHTTP1.Get('https://api.clickbank.com/rest/1.2/orders/list');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文