Php Facebook API中权限的致命错误
我发现以下Php Facebook API中权限的致命错误,php,facebook,facebook-graph-api,permissions,Php,Facebook,Facebook Graph Api,Permissions,我发现以下错误 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() {
错误
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));
问题在哪里?感谢您的帮助。您确定没有忘记
Facebook()
构造函数的参数吗
$config = array();
$config[‘appId’] = 'YOUR_APP_ID';
$config[‘secret’] = 'YOUR_APP_SECRET';
$config[‘fileUpload’] = false; // optional
$facebook = new Facebook($config);
或者您是否在代码中的其他地方初始化了$facebook
对象?在这种情况下,您应该:
- 将
传递给您的$facebook
函数以将其取回isPhotoPermission()
- 或者将
设置为$facebook
是否在另一个函数中初始化global
- 或者只需删除
$facebook=newfacebook()代码>行,如果
是在函数外部定义的(这意味着它已经是$facebook
)全局的