Feed.registerTemplateBundle

From Facebook Developer Wiki

Jump to: navigation, search

Contents

Description

Important: With the changes to the Feed system on the home page, we suggest you register template bundles with the Feed Template Console, which uses a wizard interface for you to quickly create templates.

This method builds a bundle of Feed story templates, containing a single one line template and a single short story template, registers them on Facebook, and responds with a template bundle ID that identifies your template bundle to other Feed-related API calls. You need to register at least one bundle for each of your applications. A template bundle consists of:

  • An array containing a single one line story template
  • An array containing a single short story template
  • Action links that add calls to action to your Feed stories

Each template consists of one or more tokens (for the story actor, friends, items, and so forth), some static text, and some FBML. Tokens must be wrapped in curly braces and asterisks, as in {*actor*}. The {*actor*} token must appear at the beginning of all one line templates and short story template titles. More details are discussed below.

The tokens used in a short story template are the union of the tokens used in its title and its body. A short story template must to be expressed as an array containing a single JSON-encoded object that includes the template_title, template_body, and other fields.

Note: You cannot use the words images, flash, mp3, or video as tokens in your templates, as they're reserved by Facebook for placement of media in short stories.

Registration Limits

You can have a maximum of 100 registered, active template bundles. If you're nearing the 100 template bundle limit, you can deactivate some unused template bundles using feed.deactivateTemplateBundleByID or the Registered Templates Console on the Developer site. Deactivated template bundles do not count against the 100 template bundle limit.

About Aggregation

Facebook no longer aggregates Feed stories.

Parameters

RequiredNameTypeDescription
required api_key string The application key associated with the calling application.
sig string An MD5 hash of the current request and your secret key, as described in the How Facebook Authenticates Your Application.
v string This must be set to 1.0 to use this version of the API.
one_line_story_templates array A JSON-encoded array containing one FBML template that can be used to render one line Feed stories.
optional format string The desired response format, which can be either XML or JSON. (Default value is XML.)
short_story_templates array A JSON-encoded array containing an object, which represents a short story template. The dictionary should include two fields: template_title, which should be mapped to the FBML template used to render a short story's title, and template_body, which should map to the FBML template used to render a short story's body. The token set of a short story template is taken to be the union of the template_title and the template_body templates.
full_story_template array Full story templates are deprecated, but you still should pass null for this parameter.
action_links array A JSON-encoded array of action link records, where each record contains 'text' and 'href' fields. For more information, see Action Links.

Example Requests

JSON-Encoded Template Array

'one_line_story_templates' -> ["{*actor*} just watched {*clip*} by {*artist*} on Facebook Video."] 'short_story_templates' -> [{"template_title":"{*actor*} just watched {*clip*} by {*artist*} on Facebook Video", "template_body":"{*actor*} just watched {*clip*} by {*artist*} on Facebook Video, which appears on {*album*}."}] 'full_story_template' -> null 'action_links' -> [{"text":"Watch FBTV","href":"http://www.facebook.com/video/video.php"}, {"text":"Watch {*artist*}", "href":"http://www.facebook.com/video/video.php?v={*artist-path*}"}]


Ruby Using RFacebook

one_line_story_templates = [ '{*actor*} liked the cover of {*linked_edition*}' ] short_story_templates = [ { :template_title => '{*actor*} really liked the cover of {*linked_edition*}', :template_body => 'this is the body of the short story' } ] full_story_template = nil User.find(1).facebook_session.feed_registerTemplateBundle( :one_line_story_templates => one_line_story_templates.to_json, :short_story_templates => short_story_templates.to_json, :full_story_template => full_story_templates.to_json, ) bundle_id = 0 # get the bundle id from the response edition = Edition.find 'superman-675' User.find(1).facebook_session.feed_publishUserAction( :template_bundle_id => bundle_id, :template_data => { :linked_edition => "<a href=\"#{edition.url}\">#{edition.long_name}</a>", :medium_cover => "<img src='#{edition.cover_src(380)}' />" }.to_json )


Using the PHP Client Library

$one_line_story_templates = array(); $one_line_story_templates[] = '{*actor*} liked the cover of {*linked_edition*}'; $short_story_templates = array(); $short_story_templates[] = array('template_title' => '{*actor*} has a favourite Comic Book Cover','template_body' => 'this is the body of a more generic short story'); $full_story_template = null; $action_links = array(); $action_links[] = array('text'=>'Watch FBTV', 'href'=>'http://www.facebook.com/video/video.php'); $action_links[] = array('text'=>'Watch {*artist*}', 'href'=>"http://www.facebook.com/video/video.php?v={*artist-path*}"); $facebook->api_client->feed_registerTemplateBundle($one_line_story_templates,$short_story_templates,null,$action_links);

Note: For PHP, the API expects the content to be in normal array form, not JSON.

Response

This method returns a unique integer identifier that the developer can use to publish actual stories using that template bundle.

Example Return XML

<?xml version="1.0" encoding="UTF-8"?> <feed_registerTemplateBundle_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/...> 17876842716 </feed_registerTemplateBundle_response>

Example Return JSON

[17876842716]

See Also

reference