我开发了一个将图像发布到用户帐户的 facebook 应用程序。我已经注册了那些应用程序。当我运行我的代码时,它应该将图像发布到登录的用户墙上。它只在我的帐户登录时工作。如果其他人登录并运行我的 PHP 脚本,则没有发现错误,但实际上图像没有发布到那个用户的墙上。我也禁用了沙箱。其他原因可能是什么?
如果您需要我的源代码,请告诉我。
<?php
include("facebook.php");
$filename ="50ed5eb3b33d0.png";
$facebook = new Facebook(array(
'appId' => 'XXXXXXXXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXX',
'cookie' => TRUE,
));
// Get User ID
$user = $facebook->getUser();
if(!$user)
{
$url = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'req_perms' => 'publish_stream, user_photos, read_stream, read_friendlists'
));
echo "<script type='text/javascript'>top.location.href = '$url';</script>";
}
else
{
try {
$uid = $facebook->getUser();
$facebook->setFileUploadSupport( true );
$parameters = array(
'access_token' => $facebook->getAccessToken(),
'message' => 'PHOTO_CAPTION',
'image' => '@' . realpath( './images/'.$filename )
);
$post_id = $facebook->api('/'.$uid.'/photos', 'POST', $parameters);
if(isset($post_id))
{
echo "Thank you for posting" .$uid;
unlink('./images/'.$filename);
}
}//end try getUser
catch (FacebookApiException $e) {
echo "Error:" . print_r($e, true);
}//end of catch getUser
}//end of else user
?>