3

我得到了关注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));

哪里有问题?感谢提前。

4

1 回答 1

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()函数以取回它,
  • 或设置$facebookglobal是否在另一个函数中初始化,
  • 或者如果在函数外部定义了该行(意味着它已经是),则只需删除该$facebook = new Facebook();行。$facebookglobal
于 2012-12-26T12:52:16.430 回答