Hi, I am using facebook php sdk to post on my fan site. I am trying to plan these posts in the future. However, I run into some problems. Here is my code
<?php
require_once('facebookphp/src/facebook.php');
$app_id = "xxxxx";
$app_secret = "xxxxxx";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'fileUpload' => true,
));
$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",
'message' => "test post",
'source' => "@" . "/path/to/photo.jpg",
'published' => "0",
);
$post_id = $facebook->api("/$album_id/photos","post",$args);
} else {
$permissions = $facebook->api("/me/permissions");
if( !array_key_exists('publish_stream', $permissions['data'][0]) ||
!array_key_exists('manage_pages', $permissions['data'][0])) {
header( "Location: " . $facebook->getLoginUrl(array("scope" => "publish_stream, manage_pages")) );
}
}
} catch (FacebookApiException $e) {
var_dump($e);
$user = null;
}
}
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>';
}
?>
This code sends the photo to my facebook page planned in the future, fine, except when the program runs out of time, the photo is not published. In the activity log, the photo remains in the "scheduled messages" section with the error "Sorry, something went wrong while publishing this scheduled post"
I suspected that this was due to the parameter: "published" => "0",
1, , " "