Skip to content

Instantly share code, notes, and snippets.

@mixonic
Created July 9, 2009 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mixonic/143647 to your computer and use it in GitHub Desktop.
Save mixonic/143647 to your computer and use it in GitHub Desktop.
Using multiple facebook apps with facebooker
Multiple facebook apps on one facebooker-powered Rails app. This
should be backwards compatible. For adding an app:
development:
api_key: 963285923uj23j8rj23j932
secret_key: fj329jf932jf9329t939hg239t
canvas_page_name: mainapp
pretty_errors: true
set_asset_host_to_callback_url: true
callback_url: http://www.host.com
alternative_keys:
"2a9hf29hf29f2h2f9hf29":
secret_key: jfh92h3f932h9f329f9329hf
canvas_page_name: alternativeapp
pretty_errors: true
set_asset_host_to_callback_url: true
callback_url: http://www.host.com
You can load up as many alternative_keys as desired. Really,
the "main" config has nothing special besides being the config
initialized when Rails is started. Inside a given request,
the whole app.call is wrapped in the same block regardless of
if the api_key is the main or an alternative app.
Offline tasks are a little more messy- you need to know what
app you'd like to fire something for. Once you know that,
things get cleaner:
gift = Gift.find :first
Facebooker.with_application(gift.on_app_api_key) do
FacebookerNotifier.deliver_new_gift_notification(gift)
end
As you can see in the tests, anything inside the block uses
the configuration for that api_key. Once the block ends, the
previous config replaces it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment