Posty zaplanowane za pośrednictwem interfejsu API Graph często nie są publikowane
Cześć Używam php sdk na Facebooku, aby tworzyć posty na moim fanpage. Próbuję zaplanować te posty w przyszłości. Mam jednak problemy. Oto mój kod
<?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
?>
Ten kod umieszcza zdjęcie na mojej stronie na Facebooku, która jest idealnie zaplanowana na przyszłość, z wyjątkiem sytuacji, gdy czas harmonogramu upłynie zanim zdjęcie nie zostanie opublikowane. W dzienniku aktywności zdjęcie pozostaje w sekcji „zaplanowane posty” z błędem „Przepraszamy, coś poszło nie tak, publikując ten zaplanowany post”
Podejrzewałem, że to z powodu parametru: „opublikowane” => „0”,
Jeśli usunę ten parametr lub ustawię go na 1, post nie zostanie w ogóle wykonany i pojawia się błąd „Nie można określić zaplanowanego czasu publikacji na opublikowanym postie”