【问题标题】:GetResponse API & PHPGetResponse API 和 PHP
【发布时间】:2017-03-07 00:24:04
【问题描述】:

我正在尝试使用 PHP 对 GetReponse 进行简单的 CURL 调用,但我一定是做错了什么。每次我尝试使用我的客户访问令牌时,它都会爆炸。如果我将公司 API 密钥硬编码到我放置 xxxxx 的地方,它就可以正常工作。我正在使用他们的文档,但我无法让它工作,有什么帮助吗?顺便说一句,他们的文档太糟糕了——太糟糕了,我什至无法开始完全解释!他们充满了十亿个错别字...Their Docs

        $url = "https://api.getresponse.com/v3/campaigns";
        $headers = array();
        $headers[] = "X-Auth-Token: api-key xxxxxxxxx";
        $state_ch = curl_init();
        curl_setopt($state_ch, CURLOPT_URL, $url);
        curl_setopt($state_ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($state_ch, CURLOPT_HTTPHEADER, $headers);
        $state_result = curl_exec ($state_ch);
        $state_result = json_decode($state_result);
        $debug = 1;
        print_r($state_result);

我总是得到相同的回应:

stdClass Object
(
[httpStatus] => 401
[code] => 1014
[codeDescription] => Problem during authentication process, check headers!
[message] => Unable to authenticate request. Check credentials or authentication method details
[moreInfo] => https://apidocs.getresponse.com/en/v3/errors/1014
[context] => stdClass Object
    (
        [authenticationType] => auth_token
    )

[uuid] => xxxxxxxxxxxxxxxxxxxxxxxxx
)

同样,如果我将公司 API 密钥放在 xxxxxx 的位置(我必须进入他们的控制面板),它就可以工作。访问令牌没有。

解决方案:

看起来标题需要更改为这个...

$headers[] = "Authorization: Bearer xxxxxxxxxxxxxxx"

【问题讨论】:

    标签: php curl getresponse


    【解决方案1】:

    如我所见:

    [httpStatus]401 = 未授权

    检查您的 API 令牌权限

    【讨论】:

    • 他们说“401 - 我们无法在您的请求中找到身份验证信息,如果我们无法确定您是谁,我们将无法满足您的请求。请添加身份验证标头!” -- 我说“我正在添加那个标题。”
    • 找到它:$headers[] = "Authorization: Bearer xxxxxxxxxxxxxxx" - 很高兴他们在文档中对此完全不清楚。
    • 你找到其他doc文档了吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-19
    相关资源
    最近更新 更多