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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.  
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.