gpt4 book ai didi

php - 在私有(private)配置文件上请求媒体时获取 "APINotAllowedError",即使允许所有范围

转载 作者:可可西里 更新时间:2023-11-01 00:44:31 24 4
gpt4 key购买 nike

我正在使用 PHP Instagram API https://github.com/cosenary/Instagram-PHP-API

我想检索用户的提要,即使他有私有(private)资料。

首先,我正在生成具有所有授予范围的 url

$instagram->getLoginUrl(array('basic','likes', 'relationships', 'comments'));

然后,一旦用户批准了申请,我就尝试检索他的提要

// Grab OAuth callback code
$code = $_GET['code'];

$data = $instagram->getOAuthToken($code);

// Set token
$instagram->setAccessToken($data->access_token);


// get medias
$medias = $instagram->getUserMedia($data->user->id, -1);

我收到 APINotAllowedError 错误

object(stdClass)#5 (1) {
["meta"]=>
object(stdClass)#6 (3) {
["error_type"]=>
string(18) "APINotAllowedError"
["code"]=>
int(400)
["error_message"]=>
string(29) "you cannot view this resource"
}
}

我做错了什么?非常感谢!

更新和修复

好的,实际上它来自 PHP 库,当前的 getUserMedia() 失败,因为它没有使用提供的 access_token...

这是正确的方法

public function getUserMedia($id = 'self', $limit = 0) {
return $this->_makeCall('users/' . $id . '/media/recent', true, array('count' => $limit));
}

谢谢!

最佳答案

更新:2016 年 6 月 1 日之后。您无法再通过 API 访问私有(private)资料,即使您关注/批准了该用户。您将收到错误 APINotAllowedError。如果您正在关注,查看私有(private)资料的唯一方法是使用 instagram 应用程序或 instagram.com。

但如果您的个人资料是私有(private)的,您可以使用您的 access_token

通过 API 访问它

如果用户是私有(private)的,您将无法访问个人资料。这是使用无权访问用户的 access_token 访问私有(private)用户时的正确响应

{"meta":{"error_type":"APINotAllowedError","code":400,"error_message":"you cannot view this resource"}}

只有使用已允许访问用户的用户access_token访问API,才能得到正确的响应。

关于php - 在私有(private)配置文件上请求媒体时获取 "APINotAllowedError",即使允许所有范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23701131/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com