It's been a couple of weeks since I was last in the Google's OpenSocial API. We are in the process of porting yet another Facebook application to MySpace using OpenSocial. Fortunately we wrote the original FB App with portability in mind.
Facebook vs. OpenSocial
The Facebook API and OpenSocial API use very different models making reuse very difficult. At its core, Facebook uses a Server-side proxied web application model. The Facebook server talks to your PHP-based application (which uses XML-REST API to get info from Facebook) and displays the results. OpenSocial uses a Client-Side Javascript widget model where applications are written in Javascript and get information via a Javascript API. Any external communication is done using an AJAX-like API function but all the logic is on the client-side. As a result, the development models are very different for both!
Here are a couple of suggestions to make your Facebook applications more "portable":
- Do not use the Facebook datastore, store preferences and application data in your own database
- Decouple "data" pages (pages used to generate data) from your Facebook application and access the data using includes or AJAX calls, make sure your "date" pages are stand alone and do not generate any FBML.
- Design your Facebook application to retrieve all data/information using AJAX. This take my previous point to its logical limit but since OpenSocial users Javascript/AJAX for all of its data retrieval you'll be in great shape.
- Organize your libraries to separate Facebook related functions