This method publishes a post to the user's stream using stream.publish. If you specify a 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 user and the target of the post.
This method works in one of two ways:
To display a Feed form to the user. The user does not need to have any permissions with your site to publish in this manner. If the user isn't logged into Facebook then a login popup will appear, followed by a dialog with the stream story. Users can add their own message to the post.
To publish directly to the user's stream, without any additional prompting. Before your application can publish directly, the user must grant the publish_stream extended permission. Set the auto_publish parameter to true.
This is the JavaScript client version of the stream.publish API call. You use the JavaScript call when the user may have not authorized your site, or has not granted the publish_stream permission.
You can supply a predefined object called
attachment. Facebook displays
a preview of the attachment to the user as it will look when it appears on
the user's Wall.
Prompt a user to update his or her status:
FB.Connect.streamPublish();
Prompt a user to update his or her stream with an image attachment:
var attachment = {'media': [{'type':'image',
'src':'http://bit.ly/AJTnf',
'href':'http://bit.ly/hifZk'}]};
FB.Connect.streamPublish('', attachment);
Prompt a user to post to a friend's Wall:
FB.Connect.streamPublish('', attachment, null, 4);
Prompt a user to post a image, then check the results:
function stream_callback (post_id, exception) {
if (post_id) {
post_to_my_server(post_id);
}
}
FB.Connect.streamPublish('', attachment, null, null,
'What do you think?',
stream_callback);
| user_message | String | The main user-entered message for the post. This field should typically be blank- only fill this field with content the user has actually entered themselves. |
| attachment | Object | A dictionary object containing the text of the post, relevant links, and optionally a media type. You can also include other key/value pairs which will be stored as metadata. See Stream Attachments for details. |
| action_links | Object | A dictionary of Action links objects, containing the link text and a hyperlink. |
| target_id | String | The ID of the user or the Page where you are publishing the content. If you specify a target_id, the post appears on the wall of the target user, not the user that published the post. This mimics the action of posting on a friend's Wall. |
| user_message_prompt | String | The sentence that appears before the user message field (e.g. "What's on your mind?") |
| callback | Function | A function that takes two parameters: post_id and exception. post_id returns the id of the published post (which can be null if the user cancels). exception returns error description if an error occurred. |
| auto_publish | Boolean | If the user has granted the publish_stream extended permission AND this parameter is true, then the post will be published without user approval. If the user has not set the extended permission, then the method will fail. (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. The post will appear on the Page's Wall as if the Page had posted it. (Default value is null) |