Jun
3rd
Wed
3rd
Facebook Connect: First Thoughts.
Today I spent a good part of the day digesting the somewhat haphazard documentation for Facebook Connect. The application is to be based on ASP.Net, so I’m using Monorail with ActiveRecord as the object-relational mapping (ORM) layer.
There are a few ways to go about using Facebook Connect:
-
Client-side
Just using XFMBL and javascript, basically special Facebook markup tags and AJAX to inject HTML pulled from Facebook. This is very convenient for using very common “widgets” like a FB Connect Login Button, pulling the logged in user’s name and other details like photo and his profile information even including his relationship status. But this info stays on the client side. So if you need to perform operations on the server side it becomes unclear. Furthermore, it seems you have to call FB.init on every page load to check if the user is still logged in and this degrades performance a far bit, especially with the tortoise internet connection at my work place. - Server-side
After a bit of searching, discovered a nice ASP.Net Library for Facebook Connect called Facebook Developer Toolkit. Tried to use the example from the documentation but it didn’t seem to work but there was another more recent example which works pretty well and with cleaner code than the documentation. Also comes with a nice wrapper class for the user model so you don’t have to do tedious mapping of all the profile data. What this does is it parses your browser’s Facebook cookies to retrieve and maintain your session. And it has some nice API wrappers to help you talk to Facebook. This is something I’m more familiar with especially if you have done RoR. - Hybrid
Lastly there is the hybrid, but straight out, there is a performance hit. You have to hit Facebook multiple times, once on server-side at the start of the session and on every page again for the client-side XFMBL to work.
I might just ditch XFMBL altogether if possible. Also I previously used RPX for OpenID Integration but I didn’t know how to make it play nice with Facebook Connect. But I now have a hunch that the sessionKey that RPX returns from its API might actually be the same sessionKey (the one that it parsed from the cookie) that I can use with the Facebook Developer Toolkit to access Facebook’s API. I guess if I have time I’ll look into that tomorrow.