Peter Vandenabeele
Hello World on facebook
Triggered by the article in Linux Journal of December 2007, I wrote my first "Hello World" application for facebook. Actually not that difficult, using the Rfacebook plug-in for Ruby on Rails. Installed the Rfacebook plug-in in a Ruby on Rails set-up hosted at home, used dyndns to link back home, pierced a little (?) hole in my firewall and set-up the facebook application to "call home" and use my home server as sort of web service to execute the requests to the application. Currently this only works when I am logged in myself to the application, but it is a start.
To give a clue on the simplicity of RoR, this is essentially the whole code for the application:
RubyOnRails/fb001/app$ cat controllers/hello_controller.rb
class HelloController < ApplicationController
def facebook
@result = fbsession.friends_get.uid_list
render_with_facebook_debug_panel
end
end
RubyOnRails/fb001/app$ cat views/hello/facebook.rhtml
<html>
<p>Hello World from PeterV on Facebook!</p>
<p>list of your friends</p>
<% @result.each do |uid| %>
<fb:name uid="<%= uid %>"></fb:name>
<br></br>
<% end %>
</html>
Attached is the resulting screen on facebook.
| Attachment | Size |
|---|---|
| Facebook-peterv-hello-world-faded.png | 69.29 KB |