Implementing Feed Publishing from your Website or Application
From Facebook Developer Wiki
You can publish to a user's stream on Facebook, or to the stream of one user's friend.
Depending upon the user's Facebook login state and whether he or she has authorized Facebook Connect for your site, one of following things happens:
- If the user has authorized Facebook Connect and is logged in to Facebook, you can use Feed forms to publish to the user's Wall (or the Wall of one friend of the user). Facebook will display a preview of the story, which the user then can approve. In order to automatically publish one line stories, submit your template bundles for approval on the Connect tab in the application settings editor in the Developer application. (Also, read the Stream Release Notes for more information on story sizes, Feed, and streams).
- If the user has authorized Facebook Connect and has granted your site the
publish_streamextended permission, you can use FB.Connect.streamPublish to publish directly to the user's stream or the stream of one of the user's friends. - If the user is logged in to Facebook but hasn't authorized Facebook Connect, you must use Feed forms to publish Feed stories. Facebook will display a preview of the story, which the user then can approve. Optionally, your site can prompt the user to authorize Facebook Connect, and the Feed form will appear afterward if and only if the user has authorized the site.
- If the user is not logged in to Facebook, we don't do anything, as we have no way of knowing that the user is taking action outside of Facebook.
Contents |
Publishing Using FB.Connect.streamPublish
FB.Connect.streamPublish is a versatile, easy to use method for publishing on Facebook in a number of ways. You can use the call to publish either through a Feed form or directly to a user's profile, depending on whether the user has granted your site the publish_stream extended permission.
You can also use this call to simply set the user's status, or, when you include an attachment, to publish a story with rich content like Flash or images that can be viewed inline.
Setting a User's Status
Updating a user's status is simple. Just call FB.Connect.streamPublish without any parameters. A Feed form appears, letting the user enter the status in the entry field.
Publishing a Post Containing an Image and Action Links
The following code shows how you can prompt a user to share an image in his or her stream. The image is formatted as an attachment. Learn more about attachments.
Posting to a Friend's Wall
You can also use a Feed form to prompt a user to post something to a friend's Wall. To do this, you specify a target_id parameter in your call to FB.Connect.streamPublish.
Publishing Directly to a Profile
If the user has authorized Facebook Connect for your site and has granted your site the publish_stream extended permission, you can use FB.Connect.streamPublish to publish directly to the user's stream or the stream of one of the user's friends.
You format the call the same way as you would to post via Feed form, except you need to set the auto_publish parameter to true, so the earlier code for posting an image with action links would look like this:
Publishing Posts in Other Facebook Connect Implementations
If you've built a Facebook Connect for iPhone application, you can publish back to Facebook, but in a different manner. Read more in the iPhone Connect documentation.
