public
Description: Easy creation of Facebook applications in Ruby using plugin for Sinatra web framework that integrates with Facebooker gem.
Homepage: http://www.deadprogrammersociety.com
Clone URL: git://github.com/deadprogrammer/frankie.git
Search Repo:
name age message
folder .DS_Store Sat Apr 12 19:22:56 -0700 2008 Convert Frankie into a gem to work with Sinatra... [Ron Evans]
folder .gitignore Sat Apr 12 19:22:56 -0700 2008 Convert Frankie into a gem to work with Sinatra... [Ron Evans]
folder CHANGELOG Tue Apr 22 12:38:58 -0700 2008 Bugfix for fb_url_for helper method [Ron Evans]
folder LICENSE Sat Apr 12 19:22:56 -0700 2008 Convert Frankie into a gem to work with Sinatra... [Ron Evans]
folder Manifest Mon Apr 21 20:54:01 -0700 2008 Update frankie for Sinatra 0.2.2, plus add ssh ... [Ron Evans]
folder README.rdoc Mon Apr 21 21:10:58 -0700 2008 Updates to README [Ron Evans]
folder Rakefile Mon Apr 21 21:56:47 -0700 2008 Correct Sinatra gem version for dependency, and... [Ron Evans]
folder bin/ Mon Apr 21 20:54:01 -0700 2008 Update frankie for Sinatra 0.2.2, plus add ssh ... [Ron Evans]
folder lib/ Tue Apr 22 12:38:58 -0700 2008 Bugfix for fb_url_for helper method [Ron Evans]
folder test/ Sat Apr 12 19:22:56 -0700 2008 Convert Frankie into a gem to work with Sinatra... [Ron Evans]
README.rdoc

Frankie

Frankie (http://facethesinatra.com) is a plugin for the Sinatra web framework (http://sinatrarb.com) that allows you to easily create a Facebook application by using the Facebooker gem.

Written by Ron Evans (http://www.deadprogrammersociety.com)

Based on merb_facebooker (http://github.com/vanpelt/merb_facebooker) by Chris Van Pelt, which was based on the Rails classes in Facebooker (http://facebooker.rubyforge.org/) by Mike Mangino, Shane Vitarana, & Chad Fowler

Thanks, everyone!

Here is a very simple example application:

        require 'rubygems'
        require 'frankie'

        configure do
          set_option :sessions, true
          load_facebook_config "./config/facebooker.yml", Sinatra.env
        end

        ## facebooker helpers
        before do
          ensure_authenticated_to_facebook
          ensure_application_is_installed_by_facebook_user
        end

        ## the site
        get '/' do
          body "<h1>Hello #{session[:facebook_session].user.name} and welcome to frankie!</h1>"
        end

How to use frankie

  • Install the frankie gem (which will install both Sinatra and Facebooker if you do not already have them)
          sudo gem install frankie
    
  • Create the application directories for your new app
          mkdir myapp
          cd myapp
          mkdir config
    
  • 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:
          development:
           api_key: apikeyhere
           secret_key: secretkeyhere
           canvas_page_name: yourcanvashere
           callback_url: http://localhost:4567
          test:
           api_key: apikeyhere
           secret_key: secretkeyhere
           canvas_page_name: yourcanvashere
           callback_url: http://localhost:4567
          production:
           api_key: apikeyhere
           secret_key: secretkeyhere
           canvas_page_name: yourcanvashere
           callback_url: http://yourrealserver.com
    
  • 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. A more advanced and cooler approach uses a tunneling script, which is included with Frankie. You do need to have "autossh" installed in order to use it, as well as a publicly addressable server. From a command prompt type tunnel like this:
          tunnel app.myhost.com 10000 4567
    

You will also need to make sure your server’s /etc/ssh/sshd_config contains the following line:

        GatewayPorts clientspecified

Thanks to the many people like Evan Weaver, Blake Mizerany, and whoever else that have provided the code used in this tunneling script.

  • Create your application, based on the sample above, and then run it:

ruby sample.rb

  • Test your app by going to http://apps.facebook.com/yourappname

Have fun!