Facebook API

Now I should do some work in investgate Facebook API. The Facebook API can be called as the following format( I use php as an example):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
/**
* Set the configuration settings for Facebook
*/
~~$~~facebook_config['debug'] = false;
$facebook_config['api_key'] = '<your_api_key>';
$facebook_config['secret_key'] = '<your_secret_key>';
/**
* include the Facebook client library
*/
require_once('<path_to_client_library>/facebook.php');
/**
* Set up the facebook object
*/
$facebook = new Facebook($facebook_config['api_key'],
$facebook_config['secret']);
/**
* Ensure the user has logged on to Facebook
*/
$user = $facebook->require_login();
/**
* Make an API call to call get a user's friends using the PHP library's
* library
*/
$friends = $facebook->api_client->friends_get();
echo "<pre>Friends:" . print_r($friends, true). "</pre>";
?>

The structure of the above codes is:

  • set api_key and secret_key by your own
  • send facebook_config to Facebook class and create an object of Facebook.
  • call some method of this object and get some data of facebook which you want
  • using those data to create an application
In technology, facebook uses RESTful technology, such as web services. facebook api transform data in JSON or XML format. And FBML( facebook Markup Language ) is used to combine and present data coming from developers' application servers. There are some technologic points: first, APIs should be packet into web services. Second, developers' application data should be presented in web pages. But I don't think there is new technology here.

The flow diagram of calling facebook api is:

Chinese version is here:

Facebook_API.doc