Streamlining the Open Stream APIs
by Yariv Sadan - August 5, 2009 at 1:57pm

We launched the Open Stream API in April to give developers access to a core Facebook experience, and the ability publish to users' streams. The Open Stream API supports several different publishing methods as well as the Atom-based Activity Streams framework for reading the stream.

Today, we are announcing updates to the Open API Stream, including:

  • Simpler JavaScript methods for publishing: Use the new stream.publish method in JavaScript to publish stories from your website or application.
  • Facebook Pages support: Access the stream for Facebook Pages without a session and publish to the stream on behalf of a Page.
  • Attribution: The name of your application will appear in the stream for stories published with the Open Stream API, allowing for greater visibility for applications in stream stories.

New JavaScript Methods for Publishing

With the launch of the Open Stream API, we created stream.publish, a method to simplify publishing into a user’s stream, and replacing the previous versions that relied on Feed templates. To publish stories using this method server-side, a user must first grant the publish_stream permission to your application to publish on the user’s behalf. You don't need any other permissions or approvals to use this method.

Now, we’ve created a JavaScript version of stream.publish (also available via FBJS as Facebook.streamPublish) which you can use at any time from your websites or applications. This method will always display a Feed form for the user to confirm publishing the story, unless the user has granted the publish_stream permission.

You can use these JavaScript methods from any website as a simple widget to prompt a user to publish a story even if they are not currently logged in to Facebook. They will be prompted to sign in to Facebook and then publish the story. This method can be used on any website with or without other Facebook Connect features, and will not prompt a user to Connect their accounts to your website.

Facebook Pages Support

With today's announcement, you can now access the full stream from Facebook Pages that publish posts to their streams. Using stream.get or the stream FQL table, you can access any data from Facebook Pages using the Page ID as the source ID. You don't need an active session to access a Page's stream.

In addition, we created a way for applications to publish to the stream on behalf of a Page. Once a Page admin grants permission to the application for that Page, your application can request the publish_stream permission for the Page by passing a new special parameter when you prompt for the permission. This enables a profile selector in the permission dialog. Your application can now post stories on behalf of the Page using any of the stream.publish calls just like it would for a user. You can do this through any the methods described for extended permissions including JavaScript (showPermissionDialog) or directly targeting the prompt_permissions.php URL; we'll describe the new parameters in these documents.

Attribution

For every story that gets published using any stream.publish method (the API method or either new JavaScript method listed above), we'll display the name of the application with a link that will direct to the application profile page. This feature will help users better identify from where stories are published, and more easily discover the applications their friends use.

If you are using any stream.publish method already, you don't have to make any changes. If you are using other Feed methods such as FB.Connect.showFeedDialog, feed.publishUserAction, or status.set, we recommend considering stream.publish to take advantage of this new feature. You should also review your application’s profile page to make sure it effectively represents your application or website and links to the right destination.

As always, we welcome your feedback in the Developer Forum. We can't wait to see how you'll publish into users' and Pages' streams now.