嗨我正在使用Facebook的PHP SDK发布到我的粉丝专页。我正在尝试将这些帖子安排到未来。但我遇到了一些问题。这里是我的代码通过Graph API安排的帖子经常没有发布
<?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
?>
此代码发布的照片到我的Facebook页面调度到未来的完美,当计划时间来通过照片没有公布除。在活动日志中,照片保留在'预定的帖子'部分中,错误'抱歉,出错了发布此预定的帖子'
我怀疑这是因为参数:'published'=>“0”,
如果删除该参数或将其设置为1,则该职位是不是人工做的,我得到的错误“不能指定在发布后预定的发布时间”
原来,如果我在$ post_id = $ facebook-> api(“/ $ album_id/photos”,“post”,$ args)中使用$ page_id而不是$ album_id,那么它就有点作品了。我仍然得到一个错误,说它无法发布,然后大约一个小时后,似乎无论如何发布....脸书,你很奇怪.... – 2013-02-24 15:06:26
这里同样的问题,除了在一小时内发布不是一个选项。在我们的案件中,我们的时间表很紧。 – jayarjo 2014-04-13 14:54:37
计划发布仅适用于大于10分钟的计划时间。那么你通常试图在什么时间发布照片呢? – Tobi 2014-04-14 07:51:29