Hello Facebook in Rails
I’ve signed up for Facebook today to check out how the whole application development works. Setting up a development server at home which is accessible from Facebook is pretty straight forward.
Here’s what you need:
- Facebook account
- Local box with Apache
- Domain name pointing to your home IP. I use No-Ip.
Here are the steps I took.
- Setting up development application on Facebook. Follow the guide, it’s pretty straight forward.
- Set up No-Ip to point
*.dev.mydomain.comto my local box. This allows me to create as many Rails applications as I need to. - Configured Apache to forward all calls to
fbtest.dev.mydomain.comtolocalhost:3000using mod_proxy like so:<VirtualHost *:80> ServerName fbtest.dev.mydomain.com ProxyPass / http://127.0.0.1:3000/ </VirtualHost>
gem install rfacebookcd /anywhere/fbtestrails .ruby script/plugin install svn://rubyforge.org/var/svn/rfacebook/plugins/rfacebook_on_railsrake facebook:setup- Go to http://www.facebook.com/developers/apps.php
- Copy and paste API key and secret to
config/facebook.yml. Setcanvas_pathto the local path on Facebook, ie/myfacebookapp/andcallback_pathto local path on your server, ie/facebook/. ruby script/generate controller facebook index- Edit index method in Facebook controller, like so:
class FacebookController < ApplicationController def index @result = fbsession.friends_get.uid_list end end - Edit index.rhtml like so:
<% @result.each do |uid| %> <fb:name uid="<%= uid %>" /> <% end %>
- Start Apache
ruby script/server- Now you should be able to hit your Facebook application page at
http://apps.facebook.com/myfacebookapp
You should see a list of your friends. Took me about 30 minutes to figure all this out.
12 comments.
Leave a Reply