Introduction to Facebook applications
Now let's examine the concept of a Facebook application and the tools that allow you to create these applications and to retrieve data from Facebook.
Facebook is a social networking site that was launched in 2004. At the time of this writing, Facebook has over 36 million users and, according to Alexa, is the fifth-most visited Web site on the Internet. Facebook allows users to create a profile of themselves with personal information, photos, and so on. It also allows users to communicate with each other using the "Wall", present on every Facebook user's profile.
In 2007, Facebook launched the Facebook Platform, which included a set of tools that would allow developers to create custom applications that interact with Facebook data and that users can add to their profile. At present, over 33,000 Facebook applications are available, including popular applications such as iLike and Scrabble.
As mentioned, in this tutorial you will create a sample application that resides on a Facebook user's profile. To do this, you will create what is known as a profile box. Profile boxes in Facebook can be added to the Wall or to the Boxes tab of a user's profile and are generally the starting point for a Facebook application. An example of a profile box is the Friends box, highlighted in Figure 1 below.
Figure 1. Facebook profile box
A canvas page is a dedicated page for a Facebook application, giving it enough space to present more information than can fit into a profile box. A Facebook application can have an unlimited number of canvas pages. Typically users will navigate to a canvas page by clicking on a link in a profile box. Figure 2 shows an example of a Facebook application (in this instance, the Twitter application) in a canvas page.
Figure 2. Facebook canvas page
To build a Facebook application, developers leverage the power of the Facebook Platform's tools, including Facebook Markup Language (FBML), Facebook Query Language (FQL), and the Facebook API. The sample application in this tutorial will use all three of these concepts.
basically a modified version of HTML, with some new Facebook-only tags added and
some tags modified or removed as required. FBML can be used on both profile
boxes (using the
profile.setFBML API method) and
canvas pages. FBML contains many tags that make it simple to include Facebook
features and data in your application. Facebook-specific tags in FBML have the
prefix "fb". For example
<fb:name> can be used
to output the name of a Facebook user.
FQL is a query language that allows you to access Facebook data in much the same way as SQL (Structured Query Language) is used to access data in a relational database such as MySQL. The Facebook Platform allows access to a series of FQL tables such as user, photo, album—which contains data about Facebook users—uploaded photos, and photo albums, respectively. See a full list of FQL tables.
The Facebook API is a REST-like interface for accessing Facebook data in your applications. The API is accessed by applications that make POST or GET requests to the Facebook API REST server. The API makes available many methods that allow you to easily retrieve Facebook data about users, profiles, friends, groups, photos, and more. In particular, the fql.query API method allows you to issue FQL statements that return customized results.
To make using the API easier, a number of API clients have been made available. In this tutorial you will be using the Facebook API PHP Client Library to access the Facebook API.