我开发了一个将图像发布到用户帐户的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
?>