嗨,伙计们,我是 php programin 和 facebook 应用程序的新手,我找到了这段代码,它适用于 TEXT 帖子,但我的要求是我也必须上传图片,我尝试通过 addin ['source' => '$image_source'] 在 arrey 但不起作用...我如何上传照片?
<?php
include_once("config.php");
if($_POST)
{
//Post variables we received from user
$userPageId = $_POST["userpages"];
$userMessage = $_POST["message"];
$image_source = "http://www.example.com/image.jpg"
if(strlen($userMessage)<1)
{
//message is empty
$userMessage = 'No message was entered!';
}
//HTTP POST request to PAGE_ID/feed with the publish_stream
$post_url = '/'.$userPageId.'/feed';
//posts message on page statues
$msg_body = array(
'message' => $userMessage,
'source' => '$image_source'
);
if ($fbuser) {
try {
$postResult = $facebook->api($post_url, 'post', $msg_body );
} catch (FacebookApiException $e) {
echo $e->getMessage();
}
}else{
$loginUrl = $facebook->getLoginUrl(array('redirect_uri'=>$homeurl,'scope'=>$fbPermissions));
header('Location: ' . $loginUrl);
}
//Show sucess message
if($postResult)
{
echo '<html><head><title>Message Posted</title><link href="style.css" rel="stylesheet" type="text/css" /></head><body>';
echo '<div id="fbpageform" class="pageform" align="center">';
echo '<h1>Your message is posted on your facebook wall.</h1>';
echo '<a class="button" href="'.$homeurl.'">Back to Main Page</a> <a target="_blank" class="button" href="http://www.facebook.com/'.$userPageId.'">Visit Your Page</a>';
echo '</div>';
echo '</body></html>';
}
}
?>