Jun 30, 2008

Working with New Facebook API

Facebook logo - Image Via WikipediaAs I’ve written previously, I have worked on a few Facebook applications. I’ve gotten quite familiar with the intricacies of Facebook and how things work using its API. It’s an interesting way of doing things if you ever get the chance to check it out.

Anyhow, I’ve been working for the past week or so on getting to know the new API and platform changes that Facebook should be releasing in the next month or so. While it seems that a lot of things will just work as is, there are a couple of main points that will need to be changed for any Facebook app written on the current platform.

The main change I feel is the way that the application publishes feeds. Previously, you would call the Feed.publishTemplatizedAction function. It is pretty basic and relatively easy to understand. With the new platform, this old call is being removed and to be replaced with a couple of API calls. With the old platform, you needed to register your templates, get a Template ID back from Facebook, and then use that to call your feeds whenever.

I had a lot of issues at first getting the syntax correct on how the data was passed to the feeds since there isn’t a lot of documentation on how they are supposed to look. Especially since Facebook changed the call Feed.registerTemplateBundle. But once I got the new changes implemented and the hang of it, publishing feeds stories finally worked as they once did.

The big change to the feed stories is that you are able to have 3 feed sizes. The default is the one-liner. Just like it sounds, one line of copy. Next are the short story and the full story. They are very similar with the exception that you actually register an array of short stories with each one having one less dynamic piece than the one before it. With full stories, you only register one but you can make it large. I’m not sure of the size difference between the short and full stories as I don’t think that has been decided as of yet. If so, let me know.

Those are really the only things that I have done with the new API as of yet. Seems really cool but also a lot of work to keep your old apps working seamlessly. First of all, each application that you have, you will have to run the Feed.registerTemplateBundle API function to get a template ID for your app to use exclusively. Secondly, you will have edit your API calls to now call the Feed.publishUserAction instead of the Feed.publishTemplatizedAction call being made previously. It’s not a “huge” change but still there are a few differences.

My idea for updating the apps that I have worked on was to just change the API code that we use on every project but I have seen that won’t work exactly as I had planned. Currently, I pass the entire feed story as a string into the API call but with the new way, I’m going to have to pass a JSON array because the story itself has already been registered along with the template ID. It’s not a big deal but it would be nice if Facebook made their API a little bit more backwards compatible. But I can see why they are doing it this way. Everything is changing and it would be hard to keep the old stuff working. I would like the ability to register templates like they do it currently through a form on the Facebook site. That way I wouldn’t have to create a page on each app just to get a number back and then remove that page. Seems like kind of a waste to me but it’s still early, maybe they’ll do that.

If you have worked with the new Facebook API, I would love to hear about your experiences and what you think about some of the pending changes. I’m excited to see what changes end up happening and where the platform goes.

Zemanta Pixie

2 Comments

  • I’m having so much trouble with publishtemplatized action. So, from your post it appears that they’ve gotten rid of it? That would explain why it’s not working.

    I can _fbservice.setFBML() fine, but the _fbservice.publishtemplatizedaction() isn’t doing anything! The codeples discussions aren’t really much help either

  • I believe it still works for the time being but only in the old Facebook. If you are using the new version, you have to switch over to using registed template bundles like I wrote about above. Try your app out on the old version of Facebook and I’d be curious if it did work there. Let me know.

Leave a comment