dtl19910708 2015-05-15 10:03
浏览 67

计划以PHP cURL发布到Facebook

I have been trying to post a status at scheduled date/time to Facebook using PHP cURL.

I am using the unix timestamp value to the parameter scheduled_publish_time and published=false. In Facebook I can see my post being scheduled at the given time.

but unfortunately nothing gets posted at that time and Facebook still shows the message as "next post scheduled for #time" even after the time has elapsed.

Code:

<?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);

when I run this script through terminal and var_dump() the response it gives me an output as :

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

what is the solution for this ? What necessary changes do I need to make ?

Thank you for any Help

  • 写回答

1条回答 默认 最新

  • dswy34539 2015-05-15 21:14
    关注

    Remove published=false. It means that no feed story should be created, at all.

    Using scheduled_publish_time only is what you need to create a scheduled post, that will only appear on the page’s timeline when the specified timestamp is reached.

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

    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)