我想将一张照片上传到粉丝页面提要,但我不能,我读过一次才能发送它,必须是 POST FORM!这是正确的?
索引.php
<html>
<head>
<title>Index Page Facebook</title>
</head>
<body>
<?php
require('config.php');
if($user){
$_SESSION['user_id'] = $user;
?>
<form action="facebook3.php" method="post" accept-charset="utf-8">
Message <input type="text" name="message"> <br>
Photo: <input type="file" name="pictureFile">
<input type="submit" value="Postar">
</form>
<?php
exit();
}else{
?>
<a href="<?php $facebook->getLoginUrl(array('scope' => $fbPermissions, 'redirect_uri' => $homeurl)); ?>">Login Facebook</a>;
<?php
}
?>
</body>
</html>
fb.php
<?php
include_once("config.php");
//destroy facebook session if user clicks reset
if($_POST)
{
//$loginUrl = $facebook->getLoginUrl(array('scope' => 'manage_pages'));
//$loginUrl = $facebook->getLoginUrl(array('scope' => 'publish_stream'));
@include_once("config.php");
//Post variables we received from user
$userPhoto = $_FILES["pictureFile"]["tmp_name"];
$userMessage = $_POST["message"];
if(strlen($userMessage)<1)
{
//message is empty
$userMessage = '';
}
//HTTP POST request to PAGE_ID/photos with the publish_stream
$post_url = '/228433913910358/feed';
//posts message on page statues
$msg_body = array(
'source'=>'@'.$userPhoto,
'message' => $userMessage
);
if ($user) {
try {
$postResult = $facebook->api($post_url, 'post', $msg_body );
} catch (FacebookApiException $e) {
echo $e->getMessage();
}
}else{
header("Location: index.php ");
}
//Show sucess message
if($user && !empty($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/'.$fbuser.'">Visit Your Page</a>';
echo '</div>';
echo '</body></html>';
}
}
?>
所以,我试过邮寄,直接写路径$photo,但错误仍然存在!
创建 formpost 数据失败