Publishing Feed Stories to Facebook

From Facebook Developer Wiki

Jump to: navigation, search

Once you know you have Facebook users on your site, you can start publishing Feed stories on Facebook for the actions those users take on your site. Publishing Feed stories to a friend's Feed is not currently supported in Connect.

Depending upon the user's Facebook login state and whether he or she has authorized Facebook Connect for your site, one of three things happens:

  1. If the user has authorized Facebook Connect and is logged in to Facebook, you can use Feed forms to publish short stories. 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).
  2. 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.
  3. 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.

To create a Feed dialog, use the FB.Connect.showFeedDialog JavaScript call. At this time, the policy on automatically publishing one line stories has not been finalized.

Before you can publish Feed stories, you need to register a template bundle that encompasses a Feed story in one line and short sizes. One line stories appear only on the user's profile and contribute to stories that appear in the Highlights section of the profile. Only short stories appear in the stream on a user's home page. You create the templates and register the bundle with the Feed Preview Console or the feed.registerTemplateBundle API call.

[edit] Using Feed Forms

You can create Feed forms on your site through which users can publish rich content in the form of short stories. These stories are published directly into the stream on the user's home page.

If you are publishing to a user's friend's profile (using the multFeedStory form), you can publish only to one friend's profile at a time.

Creating a Feed form with Facebook Connect is the same as creating one in an iframe. You create Feed forms with JS_API_M_FB.Connect.showFeedDialog.

Here is some sample code for calling FB.Connect.showFeedDialog:

var load_feed = function() { var comment_data = {"verb":'commented on the video ', "noun":'Sample Video', "body":'Here is text for the sample body.', "fullbody":'Here is the sample body text for a full story.', "images":[{'src':'http://www.somethingtoputhere.com/therunaround/images/runaround_image.jpg', 'href':'http://www.facebook.com'}]}; FB.Connect.showFeedDialog('83788586935', template_data, ['563683308'], body_general, null, FB.RequireConnect.require, FB.RequireConnect.promptConnect, user_message_prompt, user_message); };


Here is a picture of a Feed dialog (this isn't the Feed dialog generated from the code above):

Image:connect_feedform.png

reference