必须使用主动访问令牌来查询有关当前 user-Graph api 异常的信息

An active access token must be used to query information about the current user-Graph api exception(必须使用主动访问令牌来查询有关当前 user-Graph api 异常的信息)
本文介绍了必须使用主动访问令牌来查询有关当前 user-Graph api 异常的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试使用 Graph api 更新 Facebook 用户状态.我的代码是

I am trying to update Facebook user status using Graph api. My code is

<?php 
    require 'facebook.php'; 
    $facebook = new Facebook(array( 
    'appId' =>'389694921095423',
    'secret' =>'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    'cookie' => true
    )); 
    $access_token = $facebook->getAccessToken();
    echo($access_token);
    $me = null; 

    try 
    { 
        $uid = $facebook->getUser(); 
        $me = $facebook->api('/me'); 
        echo "Welcome User: " . $me['name'] . "<br />"; 
        //access permission
        $permissions_needed = array('publish_stream', 'read_stream', 'offline_access', 'manage_pages');
        foreach($permissions_needed as $perm) 
        {  
            if( !isset($permissions_list['data'][0][$perm]) || $permissions_list['data'][0][$perm] != 1 )
            {    
            $login_url_params = array(
                'scope' => 'publish_stream,read_stream,offline_access,manage_pages',         
                'fbconnect' =>  1,         
                'display'   =>  "page",         
                'next' => 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']      
                );    
            $login_url = $facebook->getLoginUrl($login_url_params);   
            header("Location: {$login_url}");
            exit(); 
            }
        }
        //Access permission

        $post_id = $facebook->api("/$uid/feed", "post", array("message"=>"Hello World!")); 
        if(isset($post_id)) 
        {
            echo "A new post to your wall has been posted with id: $post_id"; 
        }
    } 
    catch (FacebookApiException $e) 
    { 
        echo($e); 
    } 
?>

问题是它显示了一个运行时错误,如致命错误:未捕获的 OAuthException:必须使用活动访问令牌来查询有关当前用户的信息.我已经生成了访问令牌.我必须使用它来删除此异常的地方提前致谢

The problem is that it shows a run time error like Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. I have generated the Access Tocken. Where i have to use that to remove this exception Thanks in advance

推荐答案

换行试试:

$me = $facebook->api('/me');

$me = $facebook->api('/'.$uid); 

如果您使用的不是最新版本,也可以尝试升级您的 sdk,如果您刚刚升级了 sdk 并导致了问题,那么您可以尝试降级版本并检查.

Also try upgrading your sdk if you are not using the latest version and if you just upgraded the sdk and it caused the trouble, than you can try to downgrade the version and check.

这篇关于必须使用主动访问令牌来查询有关当前 user-Graph api 异常的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Facebook Login with Strict Mode for Redirect URIs(使用重定向 URI 的严格模式登录 Facebook)
How to retrieve post ID for a post i#39;ve just made via the Facebook API(如何检索我刚刚通过 Facebook API 发布的帖子的帖子 ID)
Facebook PHP SDK logout(Facebook PHP SDK 注销)
Facebook SDK and Graph API Comment Deleting Error(Facebook SDK 和 Graph API 评论删除错误)
PHP amp; Facebook: facebook-debug a URL using CURL and Facebook debugger(PHP amp;Facebook: facebook-debug a URL using CURL and Facebook debugger)
Can#39;t delete photo via Facebook API?(无法通过 Facebook API 删除照片?)