What are the prerequisites for Facebook streaming?

I am wondering if anyone will help me eliminate my test for stream.publish. I thought everything was right with me. Here is the code:

<?php require_once 'facebook.php'; $appapikey = 'xxxxxxx'; $appsecret = 'xxxxxxx'; $facebook = new Facebook($appapikey, $appsecret); $user_id = $facebook->require_login(); $message = "Will this status show up and allow me to dominate the world?!"; $uid = $user_id; echo $uid; $facebook->api_client->stream_publish($message,$uid); 

I expect my status to change to $ message content. Instead, it happens that my UID is echo'd, and then it gives a 500 error. I made publish_stream as well as offline_access (confirmed in the settings of my application through my profile), the API key intercepts this small bit of code for my application. What other parts should I do for this simple example to work? I find the FB documentation a little harder to put together.

- Include the official Facebook PHP library

+4
source share
4 answers

stream_publish () takes more than two arguments:

 stream_publish($message, $attachment = null, $action_links = null, $target_id = null, $uid = null) 

Where $ target_id is the user or page on which you are posting to , and $ uid is the user or page that is posting, and which by default matches your session ID. To be completely explicit, I think you need to try

 <?php require_once 'facebook.php'; $appapikey = 'xxxxxxx'; $appsecret = 'xxxxxxx'; $facebook = new Facebook($appapikey, $appsecret); $user_id = $facebook->require_login(); $message = "Will this status show up and allow me to dominate the world?!"; echo $user_id; $facebook->api_client->stream_publish($message,null,null,$user_id,$user_id); 

An alternative form may be:

 $app_id = 'xxxxxxx'; $facebook->api_client->stream_publish($message,null,null,$user_id,$app_id); 
+6
source

It works in 2011! I have the same problem. Most of them seem to be outdated due to changes in Facebook. In the end, I found a way that worked, and made a quick blog article about it here:

http://facebookanswers.co.uk/?p=214

There is also a screenshot shown to show you what the result is. Make sure you also see the authentication blog post.

+2
source

Remove the $uid variable as it is not needed for publishing. See this wiki entry for more information.

 $stream_post_id = $facebook->api_client->stream_publish($message); //returns $post_id to use if you want to revert the creation. 
0
source

If you are trying to use streamPublish with an iFrame application, here is an example step-by-step tutorial that should not use getAppPermissions:

http://thetechnicalexperience.blogspot.com/2010/02/how-to-use-fbconnectstreampublish.html

0
source

All Articles