About facebook api stream publish call.

I want to post something from within my application to the logged in users' facebook wall. I have the following code which will take the user to the facebook login page if he is not login and then back to the "canvas page url" in my application which i have set in the application settings on facebook.

I have two problems here ::

- In fb:name tag, I do not get the name of the user when we return after doing login to the facebook.

- I get fb:name output on the page only if i comment the stream_publish api call, if I include it, then there is no message posted to the wall and I get a blank page with no output.

Please help.
require_once '../../lib/Facebook/facebook.php';  
$facebook = new Facebook('apikey', 'apisecret');
$fb_user = $facebook->require_login();
$facebook->api_client->stream_publish('Hi, what are you doing right now?');
Hello <fb:name uid='<?php echo $fb_user; ?>' useyou='false' possessive='true' />! Welcome to my first application!
echo "<pre>Debug:" . print_r($facebook,true) . "</pre>";

Open in new window

Who is Participating?
mankowitzConnect With a Mentor Commented:
You have to make sure that your app has permission to stream_publish. Use try/catch to see if that line is throwing an exception.
mankowitzConnect With a Mentor Commented:
Also check to see if the call returns an error:

Code Description
1 An unknown error occurred.  
100 Invalid parameter.  
102 Session key invalid or no longer valid (if it's a desktop application and the session is missing).  
200 Permissions error. The application does not have permission to perform this action.  
210 User not visible. The user doesn't have permission to act on that object.  
341 Feed action request limit reached.  
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.