[英]Schedule posts on Facebook page with PHP SDK
我正在嘗試安排將來要添加到Facebook業務頁面的留言牆。
據我所知,Facebook不建議再使用“ offline_access”。
你會怎么做?
到目前為止,這是我的代碼。 如果我已經登錄了Facebook,它會起作用。
編輯:自然,我將創建一些代碼來檢查我從數據庫中提取的計划。 並使用Cron作業定期檢查該計划。
require_once('src/facebook.php');
$config = array(
'appId' => 'xxxxxxx',
'secret' => 'xxxxxxx',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
$page_info = $facebook->api("/PAGE_ID?fields=access_token");
try {
$ret_obj = $facebook->api('/PAGE_ID/feed', 'POST',
array (
'link' => 'http://www.example.com/',
'message' => 'This is a test',
'access_token' => $page_info['access_token']
));
} catch(FacebookApiException $e) {
$login_url = $facebook->getLoginUrl( array(
'scope' => 'publish_stream'
));
print_r($e->getType());
print_r($e->getMessage());
}
您現在必須定期擴展access_token。 所有其他代碼應能像以前一樣正常工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.