0

i have created an application where user can post message to their own wall ! this is my code

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 />';
}

it returns an error Fatal error: Call to undefined method stdClass::stream_publish() in /home/webshine/public_html/tutorials/fb/example.php on line 149 what is wrong ?

Sourav
  • 17,065
  • 35
  • 101
  • 159

1 Answers1

7

to post on wall you must use api method of facebook object.

like this.

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

You're using an old SDK methods apparently.

here is some more code

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

Community
  • 1
  • 1
Headshota
  • 21,021
  • 11
  • 61
  • 82
  • i downloaded the latest SDK from github ! can you tell me more on your code $facebook->api('/me/feed','post',$params); HOW TO USE THEM PROPERLY ? – Sourav Apr 07 '11 at 07:42
  • i got this **Error Fatal error: Uncaught OAuthException: (#200) The user hasn't authorized the application to perform this action thrown in /home/webshine/public_html/tutorials/fb/facebook.php on line 543** – Sourav Apr 07 '11 at 07:47
  • you must be authorized to post on the wall. here is the simple example of how to authorize. https://github.com/facebook/php-sdk/blob/master/readme.md – Headshota Apr 07 '11 at 07:57