我用下面的PHP代碼發佈從我的數據庫隨機郵件到我的Facebook粉絲頁面:Facebook的圖形API會話過期
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.
所以我的問題是我應該在我的代碼中做什麼改變?
P.S:我也看了會議到期的相關問題,但他們沒有一個幫助我。
在此先感謝。
的Facebook已經貶值了訪問令牌。檢查了這一點https://developers.facebook.com/roadmap/offline-access-removal/ –
@ RaquibulIslam,Facebook **不D **不贊成'access_token'但'offline_access'權限(用於獲得「永久性」'access_token') –
@JuicyScripter你是對的,我錯過鍵入那個:( –