我尝试了很多方法使用php sdk发布用户墙。但是没有成功。任何人都知道成功发布到wall.please帮助我...此代码返回任何错误但它不会发布用户时间石灰。 目前我正在使用这个PHP代码..
require_once('src/facebook.php');
$config = array(
'appId' => '#########',
'secret' => '#########################',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
echo $user_id;
$access_token = $facebook->getAccessToken();
if($user_id!=0)
{
try {$attachment = array(
'message' => "good Evening",
'name' => "good Evening",
'link' => "good Evening",
'description' => "good Evening",
'picture'=>"http://hotactresshotphotos.files.wordpress.com/2011/02/bhama_028.jpg",
'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
);
$result = $facebook->api('/'.$user_id.'/feed', 'post', $attachment);
}
catch(FacebookApiException $e) {
$login_url = $facebook->getLoginUrl( array(
'scope' => 'publish_stream'
));
echo 'Please <a href="' . $login_url . '">login.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';
} else {
$login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' ) );
echo 'Please <a href="' . $login_url . '">login.</a>';
}
答案 0 :(得分:3)
你得到的错误究竟是什么?顺便说一下,如果你有publish_stream权限,它对我有用:
$attachment = array(
'access_token' => $access_token,
'message' => "$message",
'name' => "$name",
'description' => "$description",
'link' => "$link",
'picture' => "$pictureUrl",
'actions' => array('name'=>'Try it now', 'link' => "$appUrl")
);
try{
$post_id = $facebook->api("me/feed","POST",$attachment);
}catch(Exception $e){
error_log($e->getMessage());
}