Pinterest API 未按预期工作

Pinterest API not working as expected

我正在尝试通过 PHP 使用 Pinterest API,但到目前为止它还没有真正起作用。 我使用本指南开始:

https://developers.pinterest.com/docs/api/authentication/

除了第 3 步,我现在一切正常。 文档说这只是对

的简单请求

https://api.pinterest.com/v1/me/?access_token=<YOUR-ACCESS-TOKEN>

  1. Making authenticated requests

Finally, once you have an access token, you can make authorized requests on the users behalf using OAuth 2.0 Bearer tokens supplied via the Authorization request header or via a request parameter named access_token (supplied as either a form-encoded body parameter or a URI query parameter). The Authorization header is preferred.

For example, you can visit this site on your browser:

https://api.pinterest.com/v1/me/?access_token= A sample response might look like:

{ "data": { "url": "https://www.pinterest.com/ben/", "first_name": "Ben", "last_name": "Silbermann", "id": "4788400174839062" } }

我有一个 access_token 看起来像这样:

AcFFayZKwqXuKVkj1J-0QN1fCob1FAgjuP9-OtFCg_j49UAgogXXXXX

但每次我收到这条消息时:

{"status": "failure", "code": 3, "host": "coreapp-devplatform-devapi-181", "generated_at": "Mon, 28 Sep 2015 12:28:38 +0000", "message": "Authorization failed.", "data": null}

我使用此 PHP 代码从 URL:

获取数据
        $curl = curl_init($url);
        curl_setopt_array($curl, array(
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_FORBID_REUSE => true,
            CURLOPT_FRESH_CONNECT => true,
            CURLOPT_HEADER => false,
            CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded"),
            CURLOPT_NOBODY => false,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_CONNECTTIMEOUT => 30,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_USERAGENT => self::userAgent()
        ));
        $result = curl_exec($curl);
        var_dump($result);
        $errorCode = curl_errno($curl);
        $respCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        curl_close($curl);

请看。它涵盖了您所描述的完全相同的问题。据我所知,这似乎是 Pinterest 方面的问题。来自 Pinterest 开发团队的@ZackArgyle 收到了通知并且我相信正在努力。

我刚刚经历了同样的错误,但针对的是不同的端点。试试这个代码

        $ch = curl_init();

        $url = "https://api.pinterest.com/v1/me/?access_token='YOUR_ACCESS_TOKEN'";

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        $result = trim(curl_exec($ch));
        curl_close($ch);

        print_r($result);