I have been busily working through my todo list of coding goodies with the next one on my list to start is revisiting the Facebook toolkit. This weekend I started looking at the changes in the Facebook API since the last revision of the toolkit and wanted to focus my effort on a few different dimensions including support for the core API calls, and also the social widgets now available for functions such as Like and Recommendations. With the growing popularity of Force.com Sites for public websites and e-commerce sites, these social widgets will make a very handy addition to the Force.com developers toolkit.
Whenever I am starting a new project, I like (no pun intended!) to make some early wins, even if I have to refactor them later. I'm a fan of iterative developer you see: get something cool out early, and not only does it give me something to share, but it also gives me more inspiration to forge ahead. Gone are the days where you spend weeks building frameworks and foundations. A few weeks in this economy can be the difference between having a competitive advantage and being a market leader rather than being just another person following a trend.
With the early iteration in mind, here is my first cut of some Facebook social widgets on a Force.com Sites page. They currently use an iFrame rather than the XFBML markup. My plan is to support XFBML to provide more flexibility, but I wanted to start simple and keep working.
Here is the controller code. As you can see the only real 'secret sauce' is to use the Site.getCurrentSiteUrl() and pass this back to our component (yes I am fan of using components extensively too – they make your code so much more modular and re-usable. Remember re-use it not always about making something so generic you consider every permutation which may (or may not) eventuate. Re-use is about making something simple.)
Finally, here is the component. And if you are really interested in giving it a spin, I encourage you to try it out on my sample Sites page (which also includes the Recommendations and Activity Feed Social Widgets). The Developer.force.com site also takes advantage of social widgets for eliciting visitor feedback. Check out the Summer 10 Cookie Support and Chatter Platform release pages for two more examples.