我想在Facebook页面的时间轴上发布照片,而不是使用PHP SDK的用户
以下是我正在使用的示例代码
<?php
include_once("config.php");
if($_POST)
{
if(strlen($_POST["message"])<1)
{
//message is empty
$userMessage = 'No message!';
}
//Post variables we received from user
$userPageIds = '00000000000000';
$facebook->setFileUploadSupport(true);
$userMessage = $_POST["message"];
//HTTP POST request to PAGE_ID/feed with the publish_stream
$post_url = '/'.$userPageId.'/albums';
//*
// posts message on page feed
$page_info = $facebook->api("/$userPageId?fields=access_token");
$access_token = $facebook->getAccessToken();
// Get the new album ID
$albums = $facebook->api($userPageId.'/albums','GET',array('access_token'=>$access_token));
foreach($albums['data'] as $album)
{
echo $album['name'];
if($album['name'] == 'Timeline Photos')
{
$album_id = $album['id'];
}
}
$args = array(
'message' => $userMessage,
'image' => '@' . $_FILES['img']['tmp_name'],
'aid' => $album_id,
'no_story' => 0,
'access_token' => $page_info['access_token']
);
if ($fbuser) {
try {
$postResult = $facebook->api('/'.$album_id.'/photos', 'post', $args);
} catch (FacebookApiException $e) {
echo $e->getMessage();
}
}else{
$loginUrl = $facebook->getLoginUrl(array('redirect_uri'=>$homeurl,'scope'=>$fbPermissions));
header('Location: ' . $loginUrl);
}
//Show sucess message
}
?>
此代码将照片添加到Page的时间轴专辑中,但它没有出现在页面的墙上
非常感谢任何帮助。