Facebook Graph API session expiration

Home - Facebook Graph API session expiration

Girly Saputri Staff asked 11 months ago

I use the following PHP code to publish random messages from my database to my Facebook fan page:

require_once('src/facebook.php');
$appid = 'MY_APP_ID';
$appsecret = 'APP_SECRET';
$pageid = 'MY_PAGE_ID';
$token = 'MY_ACCESS_TOKEN';

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => $appid,
  'secret' => $appsecret,
));

$message = 'Hello World';

//Information that makes up the facebook page post
$attachment = array(
        'access_token' => $token,
        'message' => $message
);

//Try to post to the facebook page
try{
$res = $facebook->api('/'.$pageid.'/feed','POST',$attachment);

} catch (Exception $e){

    echo $e->getMessage();
}

And here is src/facebook.phphttps://github.com/facebook/facebook-php-sdk/blob/master/src/facebook.php
But it return the error message something like this:

Your Answer