RkBlog

Hardware, programming and astronomy tutorials and reviews.

Example Facebook application in Django

How to make a basic Facebook application in Django with PyFacebook

Facebook is well known social web site. For developers it offers rich API that allows making web apps integrated with the site.

Everything for developers can be found on developers.facebook.com. Available to users apps are located in apps directory. Usually users do some quizzes, publish their results and compare, comment with other friends.

facbk1

Facebook app can be writen in many languages like PHP, Python, Ruby, Perl, Java. Apps are hosted on your server, not on facebook. APIs for all of this can be found on the wiki, and some support is available on the forum.

For python developers there is PyFacebook library, which helps in using the Facebook API, and in making Django apps integrated with the site. The code can be obtained from GIT repository:

git clone git://github.com/sciyoshi/pyfacebook.git

Creating new app on Facebook

Creating a Facebook integrated Django app with PyFacebook

We need a new or existing Django project. If you create a new one - set the basic configuration like database. If your done with that we can continue. The app is very simple. You can build more complex using the Facebook API, or make your website Facebook-friendly with Facebook Connect. The Facebook Connect APIs are Javascript/XFBML based and allow you to add components that allow users login using Facebook account, and comment content from your site on their walls. You can use a middleware or fbconnect to get cookie of a user that logged in with Facebook on your site (the Facebook login makes a cookie, which is used only by other facebook components).

For me the APIs that Facebook provie aren't the best thing on the net. One thing that there is no nice documentation for the PyFacebook (you have to look at the standard API docs). Second - if you go see an API description - there should be real code examples (expecialy for Connect), and linkt to things I could use also (for example you can add a comment on your website with XFBML or using JS API, but the docs on the JS API won't tell you that). Third: JavaScript API? JS making queries (FQL) ? It's hard to debug, hard to integrate with server-side websites. And some browsers don't render XFBML :) For me good API can be found at Flickr - clean REST API for read and write operations with various permissions that is managed by server-side language of your site.

RkBlog

Django web framework tutorials, 10 July 2009,

Comment article