facebook - 错误 100 在 Facebook 页面上安排帖子

标签 facebook api post schedule

我使用了以下代码。它在没有“scheduled_publish_time”的情况下工作正常,否则我会收到此错误“(#100)您无法在已发布的帖子上指定预定的发布时间”。 我之前用另一段代码注册了我的应用程序。这太奇怪了。

include_once("inc/facebook.php"); //include facebook SDK

$appId = '21xxxxxxxxxxx'; //Facebook App ID
$appSecret = '6b8f4bxxxxxxxxxxxxxd56'; // Facebook App Secret
$return_url = 'http://localhost:8888/...';  //return url (url to script)
$homeurl = 'http://localhost:8888/...'; //return to home
$fbPermissions = 'publish_stream,manage_pages';  //Required facebook permissions

//Call Facebook API
$facebook = new Facebook(array(
  'appId'  => $appId,
  'secret' => $appSecret,
  'cookie' => true,
  'fileUpload' => true
));

    $accounts = $facebook->api('/me/accounts');
$PAGE_ID = get_option('fb_post_cron_page'); // it is an option saved in WordPress

foreach($accounts['data'] as $account){
  if($account['id'] == $PAGE_ID){
    $ACCESS_TOKEN = $account['access_token'];
    }
}

$post_url = '/'.$PAGE_ID.'/photos';
$upload_dir = wp_upload_dir(); 
$upload_dir= $upload_dir['path'];


$timezone= 'Europe/Rome';
$date = new DateTime($dateStr, new DateTimeZone($timezone));

//posts message on page statues 
$args = array(
    'access_token' => $ACCESS_TOKEN,
    'source' => '@' . $image_abs_path,
    'message' => $post_message,
    'published' => true,
    'scheduled_publish_time' => $date->getTimestamp()
);

try {
    $postResult = $facebook->api($post_url, 'post', $args );
} catch (FacebookApiException $e) {
    echo $e->getMessage();
}

最佳答案

你必须将'published'设置为false

$args = array(
    'access_token' => $ACCESS_TOKEN,
    'source' => '@' . $image_abs_path,
    'message' => $post_message,
    'published' => false,
    'scheduled_publish_time' => $date->getTimestamp()
);

关于facebook - 错误 100 在 Facebook 页面上安排帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17284984/

相关文章:

php - 用于在 restful API 中高级过滤结果的 URL 设计

java - JSP 文件中的 doGet 有效,但 doPost 无效

javascript - 下载通过nodejs响应POST请求发送的文件? (无 AJAX)

c++ - 使用 GNU C++ 为 Maya 编译时出现编译器错误

django - 我应该在 django 模型管理器中进行外部 API 调用吗

java - Spring Security with Java Config - 允许 GET 方法/拒绝 POST 方法(403),没有任何明显的原因

facebook - 从服务器获取用于发布到 Facebook 粉丝页面的持久 token 的步骤是什么

php - Facebook graph api 给出了空的点赞结果

java - 如何在 Android 上的 fragment 中使用共享首选项?

javascript - ReactJS 未知 : unexpected token on React. createElement