Introduction to Facebook Platform

Adithya PR

What is Facebook Facebook is a free access socialnetworking website. Popular Features & Applications
• • • • • • •

Wall Photos Status News Feed Events Gifts Market Place

Facebook Development Framework
In 2007, Facebook launched its own platform for application development. This framework allows developers to create external applications to empower Facebook users to interact with one another in new and exciting ways. You can create both Web or Desktop application.

What’s Needed
•A valid Facebook account •Access to web server running a supported middleware language •The client library for your particular middleware language

Setting up the server
Web hosting site which supports the interested middle language. In our case its php. Few web hosting sites, ► Joyent – http://www.joyent.com (Partnered with Facebook) ► Runhosting – http://facebook.runhosting.com

Client Libraries Facebook officially supports clients libraries for both PHP and Java. There are client libraries for other languages but they fall as unoffical. Few other languages are, ASP.Net, Cold Fusion, C++, Perl, Python, Ruby etc. You can download them,

Facebook Platform
The Facebook platform consists of five components, namely
1. 2. 3. 4. 5.

FBML – Facebook Markup Language REST API Calls FQL – Facebook Query Language FBJS – Facebook Javascript Client Libraries

How Facebook Applications Work
Client Browser
1) User makes request to Facebook server 6) Facebook’s servers generates HTML and sends result to the user’s browser 5) Your application constructs an FBML display request to send to Facebook’s servers

2) Facebook servers pass user’s request to your server

Facebook Servers
4) Facebook’s servers send a response to your API call to your server

3) Your server composes an API call and sends it to Facebook’s servers

Your Web Server

Facebook Markup Language
FBML is the heart of the Facebook platform. It can be considered as an “evolved subset of HTML”, so you have many of the same tags available to you as you do in normal HTML. One major difference between typical HTML and FBML is that “normal” Javascript is stripped from your code. The tags starts with the prefix ‘fb:’ Example : To add a link to your application’s help pages on your dashboard, you simply need to add the following lines:

Just to give further idea, on how powerful FBML syntax can be.

Another possible tag of interest might be  <fb:swf> - Renders a flash object on the page of the specified absolute path. Like wise there almost 100 tags defined till now.

Client Library
Facebook’s PHP client library consists of two main object classes, • Facebook (in facebook.php), and • FacebookRestClient ( in facebookapi_php5_restlib.php)

API Primer
The REST API calls facilitates communication between our application and the facebook. These calls are kind of wrapper functions wrapping complex and sophisticated FQL calls. Few of the important call functions are, ► facebook.auth – Provides basic authentication ► facebook.feed – Provides methods to post fields ► facebook.friends – methods to query various checks on user’s friends ► facebook.notifications – methods to send messages to users. ► facebook.profile – allows you to set FBML in a user’s profile. ► facebook.users – Information about your users. ► facebook.events – provides way to access facebook events. ► facebook.groups – methods to access information for facebook groups. ► facebook.photos – methods to interact with facebook photos.

This example gives a brief understanding of client library and rest API.

The syntax for interacting with the API is abstracted into methods in the Facebook object. The PHP method ‘friends_get’ is setting up the REST call to facebook.friends.get API method

Facebook Query Language
The Facebook Query Language (FQL) is a SQL-style langague specifically designed to allow developers to interact with Facebook information. Some important difference from ANSI-SQL are, No JOINS, LIMIT, GROUP BY and ORDER BY clauses are not supported. There are only 9 tables to deal with. 1. User 2. Friend 3. Group 4. Group_member 5. Event 6. Event_member 7. Photo 8. Album



Facebook JavaScript
To minimize the threat of cross-site scripting (XSS) attacks, Facebook implemented its own Javascript for developers. Facebook srubs (remove) much of Javascript you can add to your application. Example : modal dialog box to users

You can implement AJAX functionality in Facebook using Mock AJAX framework. Example : Get date by clicking a button.

Facebook Tools
Facebook provides three important tools for learning and debugging Facebook applications in the Tool section of its developer web site. http://developer.facebook.com/tools.php
1) 2) 3)

API Test Console The FBML Test Console, and The Feed Preview Console

Building the Application
Install Developer Application
Once you have an account and have set up the server environment, the next step is to add Facebook’s Developer application. Goto http://www.facebook.com/developers And install the application

Sign up to vote on this title
UsefulNot useful