FB.Connect.streamPublish – wrestling the demons of the Facebook JS library

Yes, it’s true, I’ve officially mastered the most under documented API in history.

We are currently using the FBML method of publishing our wonderful Lord of the Rings licensed game. All has been rosey in the garden of The One Ring, until we found out that the FBJS Flash bridge is the most unimpressive piece of script I have ever seen. We found that random errors would creep into the loading of the SWF because of this bridge, and decided that the only way around it was to bite the bullet and move to iframe mode.

For those who don’t know, iframe mode basically means you can side-step all the ridiculous limitations imposed upon you by Facebook, and basically just have your application sit in an iframe, interacting with Facebook through the API and a set of Javascript client libraries. The wonderful thing is that we could keep our “invite your friends!” and other fbml based pages as fbml. Hooray!

However, what I didn’t recon on was the amazing lack of documentation and examples when it comes to working in iframe mode. The crux of any successful Facebook app lies in self-publication, encouraging the user to tell the world how he has gained a new level in growing tulips, or played his longest Scrabble word ever. We wanted to be able to do this from within the PHP (well HTML if your being a pedant), or within the SWF. Simples. You’d think so, but apparently not.

After wrestling the Javascript library to the ground, I came to the following conclusions:

  1. The Facebook Javascript client library is woefully under-documented.
  2. You need to use the FB.Connect functions, even though your application is not technically a Facebook Connect app.
  3. You need to have an xd_receiver.htm file on your server in order to communicate with the JS API.
  4. You need to configure the callback URL on the “Connect” tab of the developer settings for your app.
  5. You can then use the following code to spawn a stream post box…
<CODE REMOVED, NOW OUT OF DATE! LEAVE A COMMENT IF NEW CODE WILL BE HANDY>

It’s a starting point at least, and as I’ve spend the last few days looking for just this example, I thought it might help someone down the line. This may not be the best way to achieve my goal, all comments would be received with thanks.

Also, you may well find FB.Connect.getStatus() handy, it was how I found out that my connect settings were wrong in the app settings page.

Useful Links:

Your Comments are Awesome, Please Leave Them!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s