Talk:Feed.registerTemplateBundle

From Facebook Developer Wiki

Revision as of 21:56, 8 April 2009 by Richard Lynch (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Contents

[edit] Feature Request

We need to be able to add some sort of label to the templates. Having to organize my templates based on an ID is unnecessarily cumbersome. We have multiple apps with a lot of the same functionality. To be able to label our templates, to say use the "install" template, would be better than having to maintain a list of what template corresponds to what ID for each app.

To elaborate: my thinking here is just to add a label to the Template Bundles so that I could arrange them when loading them in using feed.getRegisteredTemplateBundles(). Thinking about it though, it would be great if we could actually use the label when using feed.publishUserAction() which would eliminate the need to get the Template Bundles so that I could then get their IDs to publish user actions. As it stands I'm probably going to just use some search term in the <one_line_story_template> node to organize templates. If the plan for this new template setup was to reduce the number of API traffic then I'm definitely going to be taking it the other way.

[edit] Nonconstructive Rants

Hm, nope, the parameters aren't quite confusing enough. I suggest you also require users to compute and send the set of all possible permutations of the token set used across all of their templates, from {1, 2, ... n} where 'n' is the total number of tokens that they are using. And if they make an error in their computations, the server should return Error Code 69, with no message. That'll put those platform developers in their place.

Seriously though, I know you're probably trying to make it so that users can do more with a single API call in order to reduce the number of network requests that need to be made, but you're reaching the point where your efforts to make things more efficient are creating a barrier to entry for new users, in terms of the complexity of the API. Each call to 'registerTemplateBundle' should only be able to register a *single* template bundle, which should consist of *exactly one* one-line template, *zero or one* short story templates, and *zero or one* full story templates. No more of this "we expect you to pass your parameters as JSON-encoded arrays of JSON-encoded objects with the following arbitrary fields of our choosing defined, and if you choose to send more than one thing in each JSON-encoded array, you must sort the JSON-encoded objects in the JSON-encoded array according to these arbitrary rules that we are providing you with" crap. It shouldn't need to be that complicated.


Agreed. I normally like facebook api's, but in this case: I can't tell whether we use this api only once to register templates once, then store this number and use it to publish stories. If we need to use it only once, why not just let us register templates the old way?? Ai yai yai

I am also confused about whether this is supposed to be used once or multiple times. I eagerly await the improved documentation.

Amen. Has anyone figured this out? Is there any good documentation that will hand-hold me through this?

I'm working on it! We realize that a lot needs to be done here. Expect something in the next week. -- Pete (User:563683308)

[edit] PHP Example

I haven't tested this at all, which is why I haven't put it into the main article. But if I read the source correctly, something like this might work (note that facebookapi_php5_restlib.php does the JSON-encoding for you):

$one_line_story_templates =
    array(
        "{*actor*} just bought {*album*} by {*artist*} from FacebookMusic.",
        "{*actor*} have been listening to a lot of {*artist*} at FacebookMusic.",
        "{*actor*} have been listening to a lot of their favorite artists at FacebookMusic."
    );
$short_story_templates = 
    array(
        array(
            "template_title" => "{*actor*} just bought {*album*} by {*artist*} from FacebookMusic.",
            "template_body" => "{*actor*} just bought {*album*} by {*artist*} from "
                               . "FacebookMusic, which includes {*song*}, {*song2*}, and {*song3*}."
        ),
        array(
            "template_title" => "{*actor*} have been listening to a lot of {*artist*} "
                                . "at FacebookMusic.",
            "template_body" => "{*actor*} have been listing to a lot of {*artist*} "
                               . "at FacebookMusic. Click the image to listen to 30 seconds "
                               . "of his latest single, {*song*}."
        )
    );
$full_story_template =
    array(
        "template_title" => "{*actor*} just bought {*album*} by {*artist*} from FacebookMusic.",
        "template_body" => "Click below to watch the latest {*artist*} video, available "
                           . "only through FacebookMusic."
    );
$feed_bundle_id =
    $facebook->api_client->feed_registerTemplateBundle($one_line_story_templates,
                                                       $short_story_templates,
                                                       $full_story_template);

--506843584 10:08, 13 September 2008 (PDT)

[edit] PHP Example

The php example on the main article page is wrong. It should be "$full_story_template=" not "$full_story_template[]="

[edit] Invalid tokens silently accepted here

You can register a template bundle with 'video' 'flash' 'mp3' etc.

That bundle just plain won't work when you go to publishUserAction with them, since those tokens are reserved, and are specially handled by publishUserAction

registerTemplateBundle should really validate and return an error before somebody writes all the code to do all the work with 'video' when they can't use the bundle anyway...

[edit] Can the images, flash, video or mp3 tokens be used without their being in the templateBundle?

I am attempting to put images or videos onto a feed. I cannot get the images nor the videos to show up when I call feed.publishUserAction. From the previous post, does that mean that these functions simply do not work or is the definition for images, flash, video or mp3 simply not required in the templateBundle?

You can't use those items (images, flash, mp3, video) as tokens. You can pass them as keys in your template_data array in feed.publishUserAction. Frex:
"images":[{ "src":"http:\/\/www.facebook.com\/images\/image1.gif", "href":"http:\/\/www.facebook.com" },{ "src":"http:\/\/www.facebook.com\/images\/image2.gif", "href":"http:\/\/www.facebook.com" }]
In other words, not only are those tokens not required in templateBundle you CANNOT have them there. You can only use those elements by providing them in publishUserAction.

[edit] {*target*}

This page makes no mention of the special token {*target*}.

Directly under the first bit about {*actor*} or perhaps right after the Note: about not using reserved tokens, something like this:

You may also use the special token {*target*} which will be replaced with the Facebook user's name of the target of the action.

For example: {*actor*} poked {*target*}

[edit] Action Links

The text at the top still references "full story".

The remainder of the documentation no longer seems to support a "full story" and instead the last parameter is "action links".

Maybe some mention of how it USED to work would be in order, or at least some reference to changing the parameter in whatever release it happened or something along those lines?

The PHP library still takes a "full_story" argument, and then "action_links" after that, even though the Facebook API seems to have replaced "full_story" with "action_links"

I can only hope that somebody somewhere finds this information useful...

reference