我关注了error
Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in /home/.../third_party/base_facebook.php on line 1106
我的功能是,
public function isPhotoPermission()
{
$facebook = new Facebook();
$access_token = $facebook->getAccessToken();
$permissions = $facebook->api("/me/permissions","GET",array('access_token' => $access_token));
if( array_key_exists('user_photos', $permissions['data'][0]) )
{
return 1;
}
else
{
return 0;
}
}
1106
行是,
1105: protected function throwAPIException($result) {
1106: $e = new FacebookApiException($result);
1107: switch ($e->getType()) { ....
通过以下代码发生错误:
$permissions = $facebook->api("/me/permissions","GET",array('access_token' => $access_token));
问题出在哪里?谢谢你的进步。
答案 0 :(得分:1)
您确定没有忘记Facebook()
构造函数的参数吗?
$config = array();
$config[‘appId’] = 'YOUR_APP_ID';
$config[‘secret’] = 'YOUR_APP_SECRET';
$config[‘fileUpload’] = false; // optional
$facebook = new Facebook($config);
https://developers.facebook.com/docs/reference/php/
或许您是否在代码中的其他位置初始化了$facebook
对象?在这种情况下,你应该:
$facebook
传递给isPhotoPermission()
函数以便将其恢复,$facebook
设置为global
是否在其他函数中初始化$facebook = new Facebook();
已在函数外定义(意味着已经$facebook
),则只需删除global
行。