Collaborative Facebook development with Facebooker

Posted: February 16th, 2010 | Author: Pierre Olivier Martel | Filed under: Facebook, Rails | View Comments

I’m currently consulting at Webdweller, a social advertisement platform that integrates with many social networks including Facebook. We are three developers on the team and we all need to collaborate building a Facebook application. Here’s a quick overview of how we did our setup.

1- Setup a local_env.rb file

Create a local_env.rb file in which you will put all your environment variables. This works great with Heroku. This technique is better explained in the article Managing Heroku environment variables for local development. The local_env.rb file is not checked in your version control. It remains on your local development machine and it’s loaded by your environment.rb file. I declare my Tunnlr and Facebook configuration keys this way :

# config/local_env.rb
ENV['FACEBOOK_API_KEY']            = '1cv10ddbd7c4374e70996071343c9ed5'
ENV['FACEBOOK_SECRET_KEY']         = '39c4c4c060a5fd8335a21e22bdb2w26c6'
ENV['FACEBOOK_CALLBACK_URL']       = 'http://web1.tunnlr.com:10521'
ENV['FACEBOOK_CANVAS_PAGE_NAME']   = 'my-facebook-app'

ENV['TUNNLR_PUBLIC_HOST_USERNAME'] = 'tunnlr917'
ENV['TUNNLR_PUBLIC_HOST']          = 'ssh1.tunnlr.com'
ENV['TUNNLR_PUBLIC_PORT']          = '10521'
ENV['TUNNLR_LOCAL_PORT']           = '3000'

# config/environment.rb
# Load heroku vars from local file
# credits: http://tammersaleh.com/posts/managing-heroku-environment-variables-for-local-development
local_env = File.join(RAILS_ROOT, 'config', 'local_env.rb')
load(local_env) if File.exists?(local_env)

Replace those values with your Facebook application keys and tunnlr keys. Each developer is going to need it’s own Facebook App and it’s own Tunnlr account.

2- Put the variables in facebooker.yml

Facebooker.yml is where “facebooker”: fetch its configurations. Reading the Facebooker source code, I realized the file is first parsed in ERB, which lets you put variables in your YAML file. We can put the variables we declared in step 1 :

development: &development
  api_key: <%= ENV['FACEBOOK_API_KEY'] %>
  secret_key: <%= ENV['FACEBOOK_SECRET_KEY'] %>
  callback_url: <%= ENV['FACEBOOK_CALLBACK_URL'] %>
  canvas_page_name: <%= ENV['FACEBOOK_CANVAS_PAGE_NAME'] %>
  pretty_errors: true
  tunnel:
    public_host_username: <%= ENV['TUNNLR_PUBLIC_HOST_USERNAME'] %>
    public_host: <%= ENV['TUNNLR_PUBLIC_HOST'] %>
    public_port: <%= ENV['TUNNLR_PUBLIC_PORT'] %>
    local_port: <%= ENV['TUNNLR_LOCAL_PORT'] %>

test:
  <<: *development

3- That’s it!

Each developer now has its own configuration for Facebook and Tunnlr and the keys are stored in local_env.rb. This file is not checked in git. This way, all the developers can then share the same facebooker.yml file.

See my other article on speeding up Tunnlr for more tips on developping Facebook applications.


blog comments powered by Disqus