Facebook Methods description: feed.publishTemplatizedAction

anna_150.jpg

Publishes a Mini-Feed story to the user corresponding to the session_key parameter, and publishes News Feed stories to the friends of that user who have added the application.

Parameters

 

string api_key The application key associated with the calling application.
string session_key The session key of the logged in user.
float call_id The request’s sequence number. Each successive call for any session must use a sequence number greater than the last. We suggest using the current time in milliseconds, such as PHP’s microtime(true) function.
string sig An MD5 hash of the current request and your secret key, as described in the authentication guide.
string v This must be set to 1.0 to use this version of the API.
string format Optional - desired response format. Either “XML” (default) or “JSON”.
string callback Optional - wrap the response inside a function call. This is primarily to enable cross-domain javascript requests using the <script> tag, sometimes known as “JSONP“. This works with both XML and JSON.
markup title_template The templatized markup displayed in the feed story’s title section. This template must contain the token {actor} somewhere in it.
string title_data Optional - A JSON-encoded associative array of the values that should be substituted into the templates in the title_template markup string. The keys of this array are the tokens, and their associated values are the desired substitutions. ‘actor’ and ‘target’ are special tokens and should not be included in this array. If your title_template contains tokens besides ‘actor’ and ‘target’, then this is a required parameter.
markup body_template Optional - The markup displayed in the feed story’s body section.
string body_data Optional - A JSON-encoded associative array of the values that should be substituted into the templates in the body_template markup string. The keys of this array are the tokens, and their associated values are the desired substitutions. ‘actor’ and ‘target’ are special token and should not be included in this array.
markup body_general Optional - Additional markup displayed in the feed story’s body section. This markup is not required to be identical for two stories to be aggregated. One of the two will be chosen at random.
int page_actor_id Optional - if publishing a story to a Facebook Page, use this parameter as the page who performed the action. If you use this parameter, the application must be added to that Page’s Feed. A session key is not required to do this.
string image_1 Optional - The URL of an image to be displayed in the News Feed story
string image_1_link Optional - The URL destination after a click on the image referenced by image_1.
string image_2 Optional - The URL of an image to be displayed in the News Feed story
string image_2_link Optional - The URL destination after a click on the image referenced by image_2.
string image_3 Optional - The URL of an image to be displayed in the News Feed story
string image_3_link Optional - The URL destination after a click on the image referenced by image_3.
string image_4 Optional - The URL of an image to be displayed in the News Feed story
string image_4_link Optional - The URL destination after a click on the image referenced by image_4.
string target_ids Optional - Comma-delimited list of ids of friends of the actor, used for stories about a direct action between the actor and these targets of his/her action. This is required if either the title_template or body_template includes the token {target}

Example Return XML

 

 

<?xml version="1.0" encoding="UTF-8"?>
<feed_publishTemplatizedAction_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</feed_publishTemplatizedAction_response>

Response

The function returns 1 on success, 0 on permissions error, or otherwise an error response. Publishing to News Feed requires understanding rules of its operation.

  • The title_template is required, and is limited to 60 displayed characters (excluding tags).
    • The markup must contain the token ‘{actor}’ somewhere, and this token should be placed somewhere such that it makes sense that the name of the actor who is performing an action (or multiple actors) may be substituted.
    • The token ‘{target}’ is also special, and is used to provide the Facebook News Feed engine with additional information about the structure of the story template. It is not a required token, but if it is used, then target_ids becomes a required parameter. At display time, {target} is substituted with the names of the friends whose ids are given in target_ids.
    • The markup may contain other tokens, which are denoted by putting curly braces {} around a string. These tokens will be substituted with specific values based on the data given in the accompanying data array.
    • The fb:name tag, fb:if-multiple-actors tag, and a tag are allowed. No other tags are allowed.
  • The body_template is optional, is limited to 200 display characters when combined with body_general (excluding tags).
    • The markup may contain the tokens ‘{actor}’ and ‘{target}’, though they are not required.
    • The fb:userlink, fb:name, fb:if-multiple-actors, a, b, and i tags are allowed. No other tags are allowed.
  • The title_data and body_data parameters must are JSON-encoded associative arrays for the story that are used to substitute specific values into title_template and body_template.
  • Two or more News Feed stories published with this method may be aggregated, which increases the likelihood of it being displayed to friends of the acting users.
    • In order for two stories to be aggregated together, the title_template and body_template markup strings must be identical, the target_ids must be the same, and the associative arrays given by title_data and body_data must also contain identical keys and values. (These pieces of data used to generate a unique identifier for this particular story.)
    • If two or more stories are aggregated, then the {actor} token is replaced with the names of all of the users whose actions are being aggregated. The fb:if-multiple-actors tag comes into effect when more there is more than one actor involved in the story.
  • The body_general markup should be used for information that does not need to match in order for the story to aggregate. It could contain, for instance, more details on one particular actor’s action (e.g. an example wallpost or gift). There should not be any tokens in this argument.
  • Up to 4 images can be displayed, which will be shrunk to fit within 75×75, cached, and formatted by Facebook. Images can either be a URL, or a facebook PID, or a facebook user ID. If it is a URL, you must own the image and grant Facebook the permission to cache it. Each image must have a link associated with it, which must start with http://. If it is a PID or a user ID, then the Facebook photo or profile pic will be displayed, subject to privacy constraints.
  • Applications are limited to calling this function ten (10) times for each user in a rolling 48-hour window.
  • The story may or may not show up in the user’s friends’ News Feeds, depending on the number and quality of competing stories.
  • You may use the Feed Preview Console to experiment with this method and see previews of your stories.

Error codes

1 An unknown error occurred. Please resubmit the request.
2 The service is not available at this time.
4 The application has reached the maximum number of requests allowed. More requests are allowed once the time window has completed.
5 The request came from a remote address not allowed by this application.
100 One of the parameters specified was missing or invalid.
101 The api key submitted is not associated with any known application.
102 The session key was improperly submitted or has reached its timeout. Direct the user to log in again to obtain another key.
103 The submitted call_id was not greater than the previous call_id for this session.
104 Incorrect signature.
330 The markup was invalid.
360 Feed story title_data argument was not a valid JSON-encoded array.
361 Feed story title template either missing required parameters, or did not have all parameters defined in title_data array.
362 Feed story body_data argument was not a valid JSON-encoded array.
363 Feed story body template either missing required parameters, or did not have all parameters defined in body_data array.
364 Feed story photos could not be retrieved, or bad image links were provided.
366 One or more of the target ids for this story are invalid. They must all be ids of friends of the acting user.

Source page

Tags: ,

Related Post

No Comments

No comments yet.

Comments RSS TrackBack Identifier URI

Leave a comment