In the last code walkthrough session, we have been discussing the basic concept of FBML. In this session, the use of client library will be discussed.

The role of Client Library

Facebook platform has provided us ways to access its features (e.g. getting the friends list of a user, user's wall etc) and the access can be done via different methods or protocol (e.g. using the Graph API). By using these APIs, we can do everything we want as long as they are allowed by Facebook. However, as these APIs are quite low-level, they are, to certain extent, not developers-friendly.

Client library (or SDK) provides us with another layer of encapsulation. Learning how to use a client library is usually easier. Besides, developers can write less code to do that same thing when compared with using the core API. However, there may be cases where we encountered limitations on the client library. For example, a client library may not be implementing the entire core API. Besides, in order to doing things in a universal way, it may not be as efficient as the core APIs.

Choosing the Right Client Library

There are numerous client libraries available. An 'official' list can be found here. There are also some SDKs released for other languages by other parties that are not included in the official list, google for it if needed.

Main factors affecting the choice of client library would be the language/technology used in writing the application and target platform. For example, if your application is actually PHP pages, you will probably use the PHP client library. If you are developing an iPhone application that needs to be integrated with Facebook, the "Facebook iPhone SDK" would probably a good choice.

The Client Library used in our 1st Facebook App

The client library used in our 1st Facebook App is a PHP client. I believe most of the online resources about writing Facebook application by using PHP are based on this client library. However, please note that this is an "older" PHP client library (as stated in Facebook Developers wiki). The most update one is "PHP 5" client library.

So, what are the differences between these 2 client libraries?

At this moment, based on the large number of applications written on the old REST API, I don't think Facebook will disable the Old REST API in the near future. It still worth to play around with the old PHP client library (and most of all, it is easy to use and understand). Having said that, do bear in mind that there are 2 PHP client libraries (it is confusing as the physical files are both named as "facebook.php").