发布到Facebook墙 - PHP

时间:2011-04-07 07:35:34

标签: php facebook facebook-php-sdk

我创建了一个应用程序,用户可以将消息发布到自己的墙上! 这是我的代码

try {
$facebook = new Facebook(FB_APIKEY, FB_SECRET);
$facebook->api_client->session_key = FB_SESSION;
$fetch = array('friends' =>
array('pattern' => '.*',
'query' => 'select uid2 from friend where uid1={$user}'));

$message = 'Hello There ...';
if ($facebook->api_client->stream_publish($message)) //149th line
echo 'message posted successfully';
} catch(Exception $e) {
echo $e . '<br />';
}

它返回错误致命错误:在第149行的/home/webshine/public_html/tutorials/fb/example.php中调用未定义的方法stdClass :: stream_publish() 怎么了?

1 个答案:

答案 0 :(得分:7)

要在墙上发帖,你必须使用facebook对象的api方法。

像这样。

$facebook->api('/me/feed','post',$params);

您显然正在使用旧的SDK方法。

这里有更多代码

How do you post to the wall on a facebook page (not profile)