我使用以下 PHP 代码将随机消息从我的数据库发布到我的 Facebook 粉丝页面:
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();
}
这是src/facebook.php
- https://github.com/facebook/facebook-php-sdk/blob/master/src/facebook.php
但它会返回如下错误消息:
Error validating access token: Session has expired at unix time 1339020000. The current unix time is 1339022625.
所以我的问题是我应该在我的代码中做哪些更改?
PS:我还查看了有关会话到期的相关问题,但没有一个对我有帮助。
提前致谢。