Feed.publishUserAction
From Facebook Developer Wiki
Contents |
Description
Facebook will deprecate this method December 20, 2009.
Please start using stream.publish, FB.Connect.streamPublish, and Facebook.streamPublish instead.
Publishes a story on behalf of the user owning the session, using the specified template bundle. By default, this method can publish one line stories to the user's Wall only.
You can use this call to publish short stories, provided
- The user explicitly previously selected the short story size in a Feed dialog, then checked the Always do this check box before publishing (the check box was removed when the Open Stream API launched in April 2009).
- The user granted your application the
publish_streamextended permission.
If you want to ensure you publish short stories, prompt the user for the publish_stream extended permission and use stream.publish. Or, use Feed forms to publish directly to users' streams. Read the Using the Open Stream API for more information about publishing to a user's News Feed/stream.
This method requires an active session key in order to be called. The API call returns true if all succeeds, or an error code otherwise.
An application can publish a maximum of 10 stories per user per day.
Note: Facebook doesn't impose this limit if your application is in developer mode and you publish stories to a user who is listed as a developer of your application. You set developer mode when you edit your application settings. This limit also is not imposed if the user has granted the offline_access extended permission to your application.
You can create Feed templates using the Feed Template Console or feed.registerTemplateBundle.
Parameters
| Required | Name | Type | Description | |
| required | api_key | string | The application key associated with the calling application. If you specify the API key in your client, you don't need to pass it with every call. | |
|---|---|---|---|---|
| session_key | string | The session key of the logged in user. The session key is automatically included by our PHP client. | ||
| sig | string | An MD5 hash of the current request and your secret key, as described in the How Facebook Authenticates Your Application. Facebook computes the signature for you automatically. | ||
| v | string | This must be set to 1.0 to use this version of the API. If you specify the version in your client, you don't need to pass it with every call. | ||
| template_bundle_id | int | The template bundle ID used to identify a previously registered template bundle. The ID is the one returned by a previous call to feed.registerTemplateBundle or when you registered the bundle using the Feed Template Console. | ||
| template_data | object | A JSON-encoded object of the values that should be substituted into the templates held by the specified template bundle. For information on forming the template_data object, see Template Data. | ||
| optional | target_ids | string | A comma-delimited list of IDs of friends of the actor, used for stories about a direct action between the actor and the targets of his or her action. This parameter is required if one or more templates in the template bundle makes use of the {*target*} token. It should only include the IDs of friends of the actor, and it should not contain the actor's ID. | |
| body_general | string | Additional markup that extends the body of a short story. | ||
| story_size | int | The size of the Feed story. You can specify 1 (one line) or 2 (short). The one line story is the default, and users have to opt into using short stories at time of publication or through their privacy settings. Otherwise, if the user has not allowed that particular size to be published through the API, then the story size will be demoted to match the user's preference. (Default value is 1.) | ||
| user_message | string | Text you specify that gets appended to a short story (only) that gets published on behalf of a user. The user must have already opted to allow your application to always publish short stories. Note: This parameter is not supported with one-line stories. |
Example Requests
Given the example template bundle in feed.registerTemplateBundle, one might have something like this in PHP:
Note that the token in the template is '{*foo*}' but the key in publishing is 'foo'.
Also note that you shouldn't JSON-encode $tokens (that is, json_encode($tokens), as Facebook does this for you.
Additionally, make sure that the $target_ids is an array of integers, not numeric strings, or you will get a "invalid target" error.
Response
The function returns a JSON-encoded array, containing true on success or an error response.
Error Codes
| Code | Description | |
| 102 | Session key invalid or no longer valid. | |
|---|---|---|
| 200 | Permissions error. If a user didn't grant your application permission to automatically publish short stories, this error gets returned. | |
| 329 | Template data must be a JSON-encoded dictionary, of the form {'key-1': 'value-1', 'key-2': 'value-2', ...}. | |
| 330 | The template data provided doesn't cover the entire token set needed to publish the story. | |
| 341 | Feed action request limit reached. | |
| 366 | One or more of the target IDs for this story are invalid. They must all be IDs of friends of the acting user. | |
| 807 | No active template bundle with that ID or handle exists. | |
| 452 | Session key invalid. This could be because the session key has an incorrect format, or because the user has revoked this session |
Notes
- You cannot use the
images,flash,mp3, orvideokeys as tokens in your templates, as they're reserved by Facebook for placement of media in short stories. - Publishing to Feeds requires you to be familiar with Feed and Feed Story Guidelines.
