Facebook.streamPublish
From Facebook Developer Wiki
Contents |
Description
This FBJS method publishes a post into the stream on the Wall of a user or a Facebook Page, group, or event connected to the user. By default, this call publishes to the current session user's Wall, but if you specify a user ID, Facebook Page ID, group ID, or event ID as the target_id, then the post appears on the Wall of the target, and not the user posting the item.
The post also appears in the streams (News Feeds) of any user connected to both the actor and the target of the post.
This method works in two ways. You can use it to publish:
- As a Feed form. Keep the
auto_publishparameter set to the default, false, so the Feed form appears. You do not need thepublish_streampermission to publish in this manner. - Directly to a user's or Page's stream, without prompting the user. Before your application can publish directly to the stream, the user or Page must grant your application the
publish_streamextended permission. If the user previously granted your application the permission to publish short stories into the News Feed automatically, then you don't need to prompt for this permission in order to call this method. Make sure you set theauto_publishparameter to true.
This method takes similar parameters to stream.publish. The main difference between calling this function and calling stream.publish is that if the user hasn't granted your application the publish_stream extended permission, or if the auto_publish parameter is set to false (the default), a Feed form appears, asking the user to confirm the post before publishing.
You can give your users the opportunity to add their own message to the post.
To provide rich content like MP3 audio, Flash, or an image, you can supply a predefined object called attachment. Facebook formats the attachment into the post. The attachment is described in Attachment (Streams).
If the user isn't logged in to Facebook when you make this call, a login dialog appears, followed by a dialog with the post data.
Parameters
| Required | Name | Type | Description | |
| optional | user_message | string | The message the user enters for the post at the time of publication. | |
|---|---|---|---|---|
| attachment | object | A dictionary object containing the text of the post, relevant links, a media type (image, mp3, flash), as well as any other key/value pairs you may want to add. See Attachment (Streams) for more details. Note: If you want to use this call to update a user's status, don't pass an attachment; the content of the user_message parameter will become the user's new status and will appear at the top of the user's profile. | ||
| action_links | object | A dictionary containing an action link object, containing the link text and a hyperlink. | ||
| target_id | string | The ID of the user, Page, group, or event where you are publishing the content. If you specify a target_id, the post appears on the Wall of the target profile, Page, group, or event, not on the Wall of the user who published the post. This mimics the action of posting on a friend's Wall on Facebook itself. | ||
| user_message_prompt | string | Text you provide the user as a prompt to specify a user_message. This appears above the box where the user enters a custom message. For example, "What's on your mind?" | ||
| callback | string | Callback to execute after the function completes. It takes three parameters:
| ||
| auto_publish | bool | Indicates whether to automatically publish to the user's stream without displaying a Feed form to the user. If the user has granted your application the publish_stream extended permission and this parameter is set to true, the post is published automatically. (Default value is false.) | ||
| actor_id | string | Allows the logged in user to publish on a Facebook Page's behalf if the user is an admin of the Page. If specified, actor_id indicates the ID of the Page that will publish the post. If the user publishes the post, the post will appear on the Page's Wall as if the Page has posted it. (Default value is null.) |
Example Requests
Prompt a user to update his or her status only.
Prompt a user to update his or her stream with an image attachment.
Prompt a user to write on his or her friend's Wall.
Prompt a user to post an image, then check results in a callback.
Notes
- This call is simply a wrapper for FB.Connect.streamPublish.
