Ein active access token muss verwendet werden, zur Abfrage von Informationen über den aktuellen Benutzer | Access-token gültig zu sein scheint

Ich habe ein access-token und haben die erforderlichen Berechtigungen, um "gefällt mir" einer facebook Seite, aber firebug gibt mir immer den Fehler im Titel. Bitte nicht Kennzeichnen diesen Beitrag als Duplikat, weil ich geschaut habe, auf die posts zu dem problem, und ich konnte Sie nicht finden, eine Antwort, die passen würde meine Fall in keinster Weise.
Ich kann nicht verstehen, warum oder wie sollte ich es lösen. Mein code ist der folgende:

utils.php

    <?php
require_once('sdk/src/facebook.php');
require_once("AppInfo.php");
/**
 * @return the value at $index in $array or $default if $index is not set.
 */
function idx(array $array, $key, $default = null) {
  return array_key_exists($key, $array) ? $array[$key] : $default;
}

function he($str) {
  return htmlentities($str, ENT_QUOTES, "UTF-8");
}
$facebook = new Facebook(array(
'appId'  => AppInfo::appID(),
'secret' => AppInfo::appSecret(),
'sharedSession' => true,
'trustForwarded' => true,
'file_upload' =>true
));
$user_id = $facebook->getUser();
if($user_id)
{
  $logoutUrl =$facebook->getLogoutUrl();
}
  else
  {
      $loginUrl=$facebook->getLoginUrl();
  }
if ($user_id) {
try {
  //Fetch the viewer's basic information
  $user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
  //If the call fails we check if we still have a user. The user will be
  //cleared if the error is because of an invalid accesstoken
  if (!$facebook->getUser()) {
    header('Location: '. AppInfo::getUrl($_SERVER['REQUEST_URI']));
    exit();
  }
}
}
?>

likes.php

      <?php

require_once("sdk/src/facebook.php"); 
require_once("utils.php");
require_once("AppInfo.php");
$permissions = $facebook->api('/me/permissions    ');
if( array_key_exists('publish_actions', $permissions['data'][0]) ) {
    //Permission is granted!
    //Do the related task
    //$post_id = $facebook->api('/me/feed', 'post', array('message'=>'Hello World!'));
} else {
    //We don't have the permission
    //Alert the user or ask for the permission!
    header( "Location: " . $facebook->getLoginUrl(array("scope" => "publish_actions")) );
}
?>
    <!DOCTYPE html>
    <html xmlns:fb="http://ogp.me/ns/fb#">
    <head>

      <style type="text/css">
      li{ 
        vertical-align: middle;
        padding-top: 1em; 
      }
    </style>
    <div id="fb-root"></div>
      <script type="text/javascript" src="/javascript/jquery-1.7.1.min.js"></script>
     <script type="text/javascript">

      (function(d, debug){
         var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement('script'); js.id = id; js.async = true;
         js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
         ref.parentNode.insertBefore(js, ref);
       }(document, false)); //loads javascript-sdk

        $(function() {
          //Set up so we handle click on the buttons
          $('#like_but').click(function(){
          FB.api(
      'me/og.likes',
      'post',
      {
        object: "http://facebook.com/216730015024772"
      },
      function(response) {
        alert(response);
      });});}); //they are closed properly, don't bother checking it. (!) Should like the 'object'
     </script>
    </head>
    <body> 
    <div style="position:fixed; display:block">
      <input type="button" value="Like" id="like_but"/>
 </div>    
</body>
</html>

Hat jemand eine Idee, warum erscheint der Fehler oder wie kann ich dieses Problem lösen? Jeder Hinweis wäre willkommen.

Hinweis: meldet sich der Benutzer in anderen index.php aber ich werde nicht hier posten, denn es gibt kein problem mit ihm, und das access-token wird immer noch gesammelt utils.php. Auch wenn die Prüfung, ob Berechtigungen in "likes.php" es funktioniert gut.

InformationsquelleAutor MihaiB | 2013-03-07
Schreibe einen Kommentar