簡體   English   中英

預定用PHP cURL發布到Facebook

[英]Scheduled posting to Facebook in PHP cURL

我一直在嘗試使用PHP cURL在預定的日期/時間向Facebook發布狀態。

我將unix時間戳值用於參數scheduled_publish_timepublished=false 在Facebook中,我可以看到我的帖子在給定的時間安排。

但不幸的是,當時沒有任何消息發布,即使時間已過,Facebook仍將消息顯示為“預定於#time的下一條消息”。

碼:

<?php
  $facebook_page_id='xxx';    
  $facebook_page_access_token="xxx";

  //Facebook page post
  $status='scheduled post'; 
  $fb_page_post="https://graph.facebook.com/{$facebook_page_id}/feeds?message=$status&scheduled_publish_time=1431683900&published=false&access_token=$facebook_page_access_token";

  $ch=curl_init();
  curl_setopt($ch, CURLOPT_URL, $fb_page_post);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_REFERER, '');
  curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
  curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);

  $fb_page_post = json_decode(curl_exec($ch));
  curl_close($ch);

  var_dump($fb_page_post);

當我通過終端和var_dump()運行此腳本時,響應給出的輸出為:

object(stdClass)#2 (2) {
["id"]=>
string(16) "1414369492218829"
["post_id"]=>
string(33) "1387602394895539_1414369492218829"
}

解決方案是什么? 我需要進行哪些必要的更改?

感謝您的任何幫助

刪除published=false 這意味着,沒有飼料的故事應該被創建, 在所有

使用scheduled_publish_time即可創建計划的帖子,僅當達到指定的時間戳記時,該帖子才會出現在頁面的時間軸上。

https://developers.facebook.com/docs/graph-api/common-scenarios#scheduledposts

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM