通过图形API计划帖子经常没有得到公布 [英] Posts scheduled via Graph API frequently do not get published

查看:121
本文介绍了通过图形API计划帖子经常没有得到公布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我使用Facebook的PHP SDK,使职位,以我的粉丝专页。我试图安排这些职位的未来。我遇到了一些问题,但。这里是我的code

Hi I'm using facebook php sdk to make posts to my fanpage. I am attempting to schedule these posts to the future. I am running into some problems though. Here is my code

<?php
// This code is just a snippet of the example.php script
// from the PHP-SDK <https://github.com/facebook/facebook-php-sdk/blob/master/examples/example.php>
require_once('facebookphp/src/facebook.php');

$app_id = "xxxxx";
$app_secret = "xxxxxx";

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => $app_id,
  'secret' => $app_secret,
  'fileUpload' => true,
));

// Get User ID
$user = $facebook->getUser();
var_dump($user); 
if ($user) {
  try {
    $page_id = 'xxxx';
    $album_id = 'xxxxx';
    $page_info = $facebook->api("/$page_id?fields=access_token");
    if( !empty($page_info['access_token']) ) {
        $args = array(
            'access_token'  => $page_info['access_token'],
            'scheduled_publish_time' => "1361642425", #an example timestamp
            'message'       => "test post",
            'source'        => "@" . "/path/to/photo.jpg",
            'published' => "0",

        );
        $post_id = $facebook->api("/$album_id/photos","post",$args);
        #echo $post_id;
    } else {
        $permissions = $facebook->api("/me/permissions");
        if( !array_key_exists('publish_stream', $permissions['data'][0]) ||
            !array_key_exists('manage_pages', $permissions['data'][0])) {
            // We don't have one of the permissions
            // Alert the admin or ask for the permission!
            header( "Location: " . $facebook->getLoginUrl(array("scope" => "publish_stream, manage_pages")) );
        }

    }
  } catch (FacebookApiException $e) {
    var_dump($e);
    $user = null;
  }
}

// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
  echo '<a href="'.$logoutUrl.'">logout</a>';
} else {
  $loginUrl = $facebook->getLoginUrl(array('scope'=>'manage_pages,publish_stream'));
  echo '<a href="'.$loginUrl.'">login</a>';
}

// ... rest of your code
?>

这code职位的照片到我的Facebook页面安排的未来完美,当计划时间来通过照片没有公布除。在活动日志照片保留在安排职位'的错误很抱歉,发生错误发布此计划后'栏目

This code posts a photo to my facebook page scheduled into the future perfectly, except when the schedule time comes to pass the photo is not published. In the activity log the photo remains in the 'scheduled posts' section with the error 'Sorry, something went wrong publishing this scheduled post'

我怀疑这是因为参数:'出版'=>0

I suspected this was because of the parameter: 'published' => "0",

如果我删除此参数或将其设置为1,则帖子完全不发,我得到的错误

If I remove this parameter or set it to 1 then the post is not made at all and I get the error 'You cannot specify a scheduled publish time on a published post'

推荐答案

调度岗位上述code,可以完美的工作我。我只是想和预定的11分钟后后,我后11分钟得到了通知和照片刊登在该专辑。

Scheduling the post with the above code, works perfect work me. I just tried and scheduled the post with 11 minutes later and I got the notification after 11 minutes and photo was published on the said album.

其实它的一些还挺Facebook的错误。

Actually its some kinda facebook bug.

只要到每个岗位,点击重新安排和15分钟车调整时间(或者不管多你)。出于某种原因,这种单独对它们进行复位和一切恢复正常,职位将按照计划再次发布自己。

Just go to each post, click on 'Reschedule' and adjust the time by a 15 minutes (or however much you want). For some reason this resets them individually and everything goes back to normal, the posts will once again post themselves according to schedule.

我知道这是修复一些东西,Facebook的应该靠自己解决一个单调乏味的方式,但它的作品。

I know this is a tedious way to fix something which Facebook should fix on their own, but it works.

这篇关于通过图形API计划帖子经常没有得到公布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆