访问用户令牌时出错OAuthException:必须使用活动访问令牌来查询有关当前用户的信息

时间:2012-06-18 06:32:37

标签: php facebook oauth facebook-php-sdk

我一直在寻找这个错误,但我仍然没有找到任何阻止它发生的事情,事情是它有时只会发生,而且我的错误日志上又出现了另一个错误

There exists a cookie that we wanted to clear that we couldn't clear because headers was already sent. Make sure to do the first API call before outputing anything
PHP Fatal error:  Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in /...fb_sdk/base_facebook.php on line 1106

以下是我在config.php上使用的代码,我在我的应用程序内的所有页面上使用它

<?php
    header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');

    require 'fb_sdk/facebook.php';

   $app_id = 'XXXXXXXXXXXX';
   $app_secret = 'XXXXXXXXXXXX';
   $app_namespace = 'minstagram';
   $app_url = 'https://apps.facebook.com/' . $app_namespace . '/';
   $scope = 'email,publish_actions,user_photos,friends_photos';

   // Init the Facebook SDK
   $facebook = new Facebook(array(
     'appId'  => $app_id,
     'secret' => $app_secret,
     'cookie' => true
   ));

   // Get the current user
   $user = $facebook->getUser();

   // If the user has not installed the app, redirect them to the Auth Dialog
   if (!$user) {
     $loginUrl = $facebook->getLoginUrl(array(
       'scope' => $scope,
       'redirect_uri' => $app_url,
     ));

     print('<script> top.location.href=\'' . $loginUrl . '\'</script>');
   }


?>

所以这是我的问题,希望任何人都可以在这里帮助我,也许是一种获得新的acces_token的方法,如果我当前拥有的那个无效,或者是anythig。提前谢谢!

0 个答案:

没有答案