Harry Tormey

October 1, 2009

HelloPylons: A hello world example for Facebook using Pylons and PyFacebook

As a follow up to my talk at the PyWebSF meet up I decided to put together a “hello world” style facebook app. The goal of the app is to illustrate clearly the relationship between what gets displayed on your facebook app’s canvas page and what get’s sent back to the sever hosting your app via it’s facebook callback. You can download this application here. To reiterate some points I made in my presentation, the basic flow of a facebook application is like so:

  • Someone visits your application (i.e http://apps.facebook.com/yourapp/), what they see is the canvas.
  • Visiting the canvas causes facebook to makes a callback to your application (i.e http://www.harryisawesome.com/yourapp/callback/)
  • The information passed by facebook in the callback is parsed by your application which then determines what gets returned and hence displayed in the canvas.
  • Think proxy (indirect connections).
The full list of goals for the HelloPylons application are: Keep syntax as simple as possible (no decorators, etc), Keep all logic in the controller so its easy for a Pylons novice to see whats going on, print and decode everything that gets sent in the facebook callback to the console in plain english.

The application comes bundled with the pyfacebook library and assumes that you have read chapter two and three of the excellent freely available pylons book and or are familiar with the basics of how Pylons works. I also assume that you have read the facebook developer getting started page.

In order for this demo to work you will need to edit development.ini, change the port to something appropriate and add the api_key, app_id, url and secret key for your application. All of these should be provided when you create an application on facebook (follow the instructions on the facebook developer getting started page).

1 Comment »

  1. [...] the excellent freely available pylons book and or that you know your way around Pylons. Unlike my facebook example this demo should serve straight out of the box (after you serve up development.ini with paster [...]

    Pingback by JqueryTwitter: A simple Twitter Pylons example using Jquery and python-twitter « Harry Tormey — October 4, 2009 @ 7:01 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress