Instagram API:我没有 access_token

Instagram API: I get no access_token

我正在使用 this PHP Instagram Client 尝试访问 Instagram 的 API,但每次我尝试访问它时,我都会在 return 中收到此消息:

object(stdClass)#4 (1) {
  ["meta"]=>
  object(stdClass)#2 (3) {
    ["code"]=>
    int(400)
    ["error_type"]=>
    string(25) "OAuthAccessTokenException"
    ["error_message"]=>
    string(37) "The access_token provided is invalid."
  }
}

我不知道我做错了什么。

到目前为止,这是我的代码:

$instagram = new MetzWeb\Instagram\Instagram('......');
$result = $instagram->getPopularMedia();
var_dump($result);

当我检查我的 $instagram 对象时,里面的数据似乎不正确,因为似乎没有访问令牌。

object(MetzWeb\Instagram\Instagram)#3 (7) {
  ["_apikey":"MetzWeb\Instagram\Instagram":private]=>
  string(32) "...."
  ["_apisecret":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_callbackurl":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_accesstoken":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_signedheader":"MetzWeb\Instagram\Instagram":private]=>
  bool(false)

我缺少什么?

如您在 github 存储库中所见:

Note: On the 17 Nov 2015 Instagram made changes to their API . Apps created before Nov 17, 2015 wont be affected until Jun 2016. Apps created on or after Nov 17 2015 will require to use their updated API. Please note that this library doesn't yet support their new updates. For more information, please see #182.

这意味着图书馆还不支持最新的 Instagram API。

更新: Instagram 仅允许经过身份验证的 API 调用,不再允许 public 调用。

绕过 public 调用的唯一方法是通过来自 Instagram 的 'scraping' 数据。那里有几个刮刀。

它基本上获取:https://www.instagram.com/jerryseinfeld/media/ 并解析 JSON。您可以通过从消息中获取#tags 来获取所有标签。