So you want to create a small Facebook application... seems like it should be a small thing, right? But creating an entire Ruby on Rails application just for a tiny little Facebook application is, at the very least, a bit wasteful. In the case of a overly popular Facebook app you could end up with, as Marc Andreessen put it, a "self-inflicted denial of service attack", unless you have both a pretty serious infrastructure to support it, as well as lots of cash to keep that data center running.
Wouldn't you rather be able to create a highly scalable "hello, world" Facebook application in around 13 lines of Ruby code? Say hello to Frankie:
set_option :sessions, true
load_facebook_config "./config/facebooker.yml", Sinatra.env
## facebooker helpers
## the site
get '/' do
body "<h1>Hello and welcome to frankie!</h1>"
Frankie is a plugin for the minimalist and very fast Sinatra web framework that allows you to easily create a Facebook application by using the Facebooker gem. Why would you want to use it? If your Facebook application needs to be highly scalable, is fairly small, or is really a mashup of other web-available resources, than Frankie could be a good solution.
Frankie is available now for your enjoyment. Here is how to get started:
- Install the Frankie gem, which will install the Sinatra and Facebooker gems if you do not already have them.
sudo gem install frankie
- Create the application directories for your new app:
- Put your facebooker.yml file into the /myapp/config directory, and set the values to your information. Here is a simple example of the file:
- Make sure you have setup your facebook application on the facebook site. Google "setup new facebook application" if you are unsure how to do this. I recommend starting with an IFrame application, so that you can point a development version of your Facebook application to your local machine. This, like our example here, would use "http://localhost:4567" as the callback URL when configuring the Facebook app.
- Create your application, based on the sample above, and run it:
This will start the Sinatra Ruby web server running:
== Sinatra has taken the stage on port 4567!
- Test it by pointing your browser to http://apps.facebook.com/yourappname. If you have things setup correctly then you should see your application appear inside of Facebook's site.
Facebook is now your playground... have fun with Frankie!