Tuesday, July 8, 2008

Facebooker with Bebo Support

I think I promised this quite a few months ago and now with the wonders of GitHub I have completed it.

I forked the main repo from mike and added support not only for Bebo but for running multiple Facebook apps within one Rails instance. The fork is hopefully only temporary as I think Mike will push this into the main repo once it is confiremed that it doesn't break backward compatibility. Anyone out there running on Bebo and want to kick the tires for me? If so you can grab it from :

http://github.com/digidigo/facebooker/tree/master

Basically how it works is that you can add any number of config options to your facebooker.yml file now mine looks like this:

development:
api_key: b9f5233d4b7f8216253c0d27f60603ed
secret_key: XXXXXXX
canvas_page_name: mwavedev
callback_url: http://staging.travelerstable.com:8888
bebo_api_key: pZwnITIadEri1V0fNPxEMhSen9VBCoRf5jV9
bebo_secret_key: XXXXXXX
bebo_canvas_page_name: ttdev
bebo_adapter: BeboAdapter
foo_api_key: f688cbe01c465d71e4f9bed26722309a
foo_secret_key: XXXXXX
foo_canvas_page_name: sumobaby
foo_adapter: FacebookAdapter
tunnel:
public_host_username:
public_host:
public_port: 4007
local_port: 3000



Currenlty you need to set all 4 parameters , api_key, secret_key , canvas_page_name and adapter for any additional contexts. The way the code works is that there is a before filter added to the controller that looks at fb_sig_api_key and loads an adapter instance specified by the "#{key_base}_adapter" setting for that api_key.

All of the API specific constants have been pulled out of the code base and are available via method on the Facebooker module.

For example you call Facebooker.canvas_page_name and you will get the current adapters canvas_page.

If you need to load an adapter specifically you call Facebooker.load_adapter(:config_key_base => "foo")

All the tests are passing so I think the backward compatibility is fine. And there are new tests for all the adapter specific stuff.

8 comments:

denny said...

Hello,

I think its great that you added in support to facebooker for bebo. I followed the conventions listed in this article with the most recent version of facebooker on github, but was not able to get my app working with bebo. Do you have a working version of bebo and facebooker? If you do that would be greatly appreciated. Best.

Dave said...

My current app is running on the latest facebooker and runs in Bebo and Facebook. You can post to the facebooker-talk mailing list and maybe with some more information we can help you out.

findchris said...

Did this eventually get merged back into the main facebooker branch? I can't find any docs on github to that effect.

Thanks!

Dave said...

Yes, this has gotten merged into the main branch. I'll put a note up on github.

findchris said...

Thanks for the reply. Is the config yaml format exactly as indicated in this post then? I found the BeboAdapter, but couldn't find the code indicating support for multiple Facebook apps through Facebooker.

Thanks for the valuable contribution!

Dave said...

It should still work. This code right here will support a second app called sumobaby

foo_api_key: f688cbe01c465d71e4f9bed26722309a
foo_secret_key: XXXXXX
foo_canvas_page_name: sumobaby
foo_adapter: FacebookAdapter

FYI: Someone just published an alternative solution to this using a database to look up the appropriate app. You can find that on the facebooker-talk mailing list archives.

findchris said...

Just curious: I didn't see a setting like "bebo_callback_url". Was this an oversight, or is there an assumption here that we should know about?

Cheers.

Dave said...

Yeah. not sure if it has changed since the code was integrated into the main branch, but.... The assumption is that the callback URL is the same for facebook and bebo. Routes can allow you to handle different paths after that.