Publisher
From Facebook Developer Wiki
Contents |
The Publisher is the primary feature for users to post information and messages on their own Wall and on their friends' Walls, or directly into their streams from the Publisher on the home page. Users can use the Publisher to create rich content including posting photos, sharing videos, writing notes, and whatever content ideas applications can provide. The Publisher is the central focus of communication and sharing in the user profile. It sits right on top of a user's Wall and home page, inviting the user or others to add content. Applications can integrate into the Publisher to provide rich experiences for creating or finding content to post into their own and their friends' Feeds.
The Publisher replaced the old Wall Attachments feature. Wall is just one application for creating content (text content), on par with posting links, or uploading photos or videos. Users post videos to their friends' Feeds just as if they were writing Wall posts. They can add additional text comments along with the content posted through the Publisher. Once a story is posted through the Publisher, it appears immediately in the stream.
Below the Publisher box is a series of options for the types of content that the user can create. Clicking one of the options expands the Publisher box inline to the appropriate interface.
Any application that supports the Publisher integration is eligible to appear in the list presented to a user. Applications are sorted with default applications first, and then by how recently the application was used to create content or simply used by the user. When viewing a friend's profile, the applications appear in the friend's Publisher is determined by which applications the friend uses and what applications have been used recently to post content on the friend's profile.
The Publisher interface looks similar to the user when viewing her own profile as when viewing a friend's profile, but the content options or publishing interface may differ. Applications can register a different interface for publishing on a profile owner's profile and for publishing on a friend's profile. For example, the Photos application may allow for a user to post a full album to her own profile, but on a friend's profile, the interface could change to only allow four photos to be uploaded.
When a user creates content via the Publisher, it appears as a short story on the user's Wall or the friend's Feed.
Before You Begin Integrating
Before you start integrating your application into the Publisher, you need to know the details about it. Keep the following in mind as you create your Publisher integration:
- Build a fluid layout: On a user's profile, the available width for a Publisher box's content is 514 pixels, whereas on the home page (News Feed), the Publisher is 480 pixels wide. The height of the Publisher should not exceed one page (700 pixels) in height.
- In order for your Publisher to fit properly on any page in which the Publisher appears, your Publisher should have a fluid width, being able to dynamically resize itself depending on context. This means that instead of hard-coding dimensions into your Publisher's markup, you should use block-level elements to fill the entire space of their containers.
- Note: As announced on the Platform Status Feed, we no longer support the publisher_mode setting in the application settings editor or in calls to admin.getAppProperties and admin.setAppProperties. If your Publisher integration still uses a wider legacy layout, the Publisher will appear inline, with scrollbars added so users can see all the content.
- Rich features: The Publisher allows a permissive flavor of FBML, automatically playing Flash, and supports onload FBJS. However, you cannot include external JS files or CSS.
- Commenting ability: The Publisher includes a text box for comments that appears at the top.
- FBJS: You can use FBJS to enable/disable the Share button until the user finishes the publish form.
Understanding the Publisher
In order to make the Publisher option available for your application, you need to specify a text label and a callback URL in your application settings.
Note: You can find the Publisher Callback URLs on the Profiles tab in the application settings editor.
There are two sets of these options available: one for when a user publishes to his or her own profile (Self-Publish Text and Self-Publish Callback URL in your application's settings) and one for when a user publishes to a friend's profile (Publish Text and Publish Callback URL in your application's settings). You can choose to specify either set or both. The Publisher text specifies the label that appears for your option (like specifying an attachment action today).
Once a user has authorized your application, your application appears in the Publisher interface to that user.
When a user interacts with the Publisher, Facebook sends two requests to your application: the first to render your version of the Publisher interface and the second to request the content for the Feed story that gets generated when the user publishes the content. To differentiate these two requests, you need to test for the 'method' POST parameter (using the same values you need to return in the 'method' JSON).
Publisher Parameters
Facebook always passes the following parameters in a request when a user interacts with the Publisher:
- fb_sig_api_key: Your application's API key.
- fb_sig: A signature using your application's secret key to encrypt the request.
- fb_sig_in_canvas: This parameter is always false or 0 because the Publisher is not a canvas page.
- fb_sig_request_method: This is always a POST method.
- fb_sig_locale: This is the user's locale.
- fb_sig_time: The time that the request was made.
- fb_sig_added: Indicates whether the user has authorized (agreed to your Terms of Service) the application.
- fb_sig_profile_user: Indicates the user whose profile is being published to.
- fb_sig_user: The ID of the user interacting with the Publisher.
- method: Indicates if the Publisher is getting the application's Publisher interface or getting the Feed story.
In addition, Facebook passes the following parameters only if the user interacting with the Publisher has authorized your application:
- fb_sig_profile_update_time: The last time the user profile was updated.
- fb_sig_session_key: The user's session key.
- fb_sig_expires: The time the session key expires.
Finally, Facebook passes a session secret parameter to an SWF object in your Publisher:
- fb_sig_ss: The session secret, used in place of your application's secret key for secure API calls. This is sent only to a SWF that resides within the domain or subdomain of your application's callback URL.
Rendering the Publisher to the User
When the Publisher is available for your application and a user elects to publish content with your application, a request is made to the specified callback URL. The callback URL should respond with the data needed to render the interface for the user to publish content to a profile.
In addition to the parameters specified above, when rendering the Publisher interface, Facebook also passes a parameter method, which is set to publisher_getInterface. You must include this method in your response.
Example JSON Response
The parameters for your response are described in the following table.
| Parameter | Description |
|---|---|
| method | This parameter must be set to publisher_getInterface.
|
| content | The data for the actual response. |
| fbml | The FBML that should be rendered in the Publisher. The user interacts with this FBML to create content. |
| publishEnabled | Specifies whether the Share button is enabled immediately in the Publisher. This parameter defaults to false.
If |
Configuring Your Publisher Content
Once the user interacts with the Publisher and goes to publish the content (by clicking Share in the Publisher), another request gets made to the same callback URL, passing all the parameters specified above. In addition, Facebook passes additional parameters:
-
method, which is set topublisher_getFeedStory. You must include this method in your response. - For each custom application parameter, a parameter named
app_params[...], where the...is the name of the the parameter. So if your application had a field namedmy_property, a parameter namedapp_params[my_property]will be included. -
app_params['comment_text'], which contains the message that the user entered when publishing this story.
You can format the content in app_params in one of two ways:
- As a stream attachment (this is a beta feature that will be the recommended Publisher attachment method after the new Inbox is available to all users).
- As a templatized Feed story.
Using a Stream Attachment for Content
You can create a stream attachment to use as your Publisher content. This method works only with the new Inbox.
You return the attachment as a JSON-encoded object.
Example JSON Object Stream Attachment
The parameters for your response are described in the following table.
| Parameter | Description |
|---|---|
| content | The data for the actual post. It's an array that contains the elements of the stream attachment, like the media type and descriptors for the content. This parameter must be set to attachment.
|
| method | This parameter must be set to publisher_getFeedStory.
|
Using a Templatized Feed Story for Content
You can create a templatized Feed story as your Publisher content. You need to create a Feed story template with either the Feed template console or by calling feed.registerTemplateBundles].
Note: When a user publishes content to a friend's profile, the {*target*} token in the Feed template is replaced with the friend's full name. When a user publishes content to his or her own profile, the {*target*} token is replaced with an empty string .
Important! The new Inbox has launched to all users, so we encourage you to use the stream attachment method, described above, for you Publisher integration.
You return the Feed story as a JSON-encoded object.
Example JSON Object Feed Story
The parameters for your response are described in the following table.
| Parameter | Description |
|---|---|
| content | The data for the actual Feed story. It's an array that contains the elements of the Feed story, like template references. This parameter must be set to feed.
|
| method | This parameter must be set to publisher_getFeedStory.
|
Error Codes
In case an error occurs -- for example, if the user submitted some invalid data in the Publisher interface -- the callback URL can also respond by rendering an error. The following illustrates a JSON-encoded error:
Currently the only error code supported is the value 1, which indicates a validation failure on the application’s behalf.
Testing Your Integration
You can easily test your integration by trying it on the home page: http://www.facebook.com/?pub=[app_id]
Publisher Demos
A Facebook application developer has created a screencast providing an overview of publisher usage at Publisher.
Or check out this example using .NET Facebook Developer Toolkit 2.0, the CSharp InLine Publisher.

