From bit to a heart beat

insane innovations from a sane insanity

Wed Jan 6

Facebook Connect for web2py

Even though web2py has support for building facebook applications, we didn’t have a way to use Facebook Connect.

I’ve studied many ways (like Facebook’s Javascript API) and checked other frameworks (Rails and Django) and after 4 hours I made a patch to facebook.py that enables web2py (and I’m sure that other python frameworks can use - like webpy) to use Facebook Connect by doing this:

def index():
   connected = facebook_connect(request, facebook_settings)
   if connected:
       user = get_facebook_user(request.facebook)
       response.flash = "Hello ", user       
   return dict(api_key=facebook_settings.FACEBOOK_API_KEY)

Just one line of code and you are done!

You can check a live example here and grub the code from github

Comments (View)
blog comments powered by Disqus