Facebook Graph API Introduction

Facebook uses Graph API platform for developers to develop applications. The main purposes of Facebook applications are reading and writing data using Graph API.

Facebook’s core is the social graph: people and the connections.  The basic concept of Open Graph is to put people on the web and then create appropriate connections between them.

And the concept of Facebook Graph API can be simplified as: objects and connections.

Objects

In Facebook Graph API, every object has a unique ID. Facebook
Graph API provides an easy way accessing Facebook objects:

https://graph.facebook.com/ID

The ID in the above URL can be a user ID or user name. It can also be Pages, Events, Groups, Applications, Status Message, Photos, Photo Albums, Videos and Notes.

Note:
ME can also be used for the ID to represent the current Facebook login user.

https://graph.facebook.com/ME

Let’s take some examples to illustrate how to access the Facebook objects.

Access object (people) with user ID

https://graph.facebook.com/user_id

Note:
The output return is in JASON format. You can extract the individual element easily with some simple script, for example, PHP or JavaScript.

Access object (people) with username

https://graph.facebook.com/username

Access Information of Facebook Pages

https://graph.facebook.com/Pages

Access Information of Events

https://graph.facebook.com/Events

Note:
An access token is required to request this resource.

More examples can be found at Facebook documentation:

http://developers.facebook.com/docs/reference/api/

Connections

Another Facebook core concept is connections – establish appropriate connections between objects.

All of the objects in the Facebook social graph are connected to each other via relationships. For example: Alex is a fan of the MyGreatNameHosting Page, and Alex and Kathy are friends. The connections between objects can be examined easily using the following URL structure:

https://graph.facebook.com/ID/CONNECTION_TYPE

The connections supported for people and pages include Friends, Likes, Books, Movies, Music, Events, etc…

To access the connection, you need to obtain an access token for the user to perform authorized requests on behalf of that user.  This can be done by including the access token in your Graph API requests:

https://graph.facebook.com/ID/CONNECTION_TYPE?access_token=…..

Let’s also take some examples to illustrate how to examine the connections between objects:

Connections or Relationship with Friends

Connection with Books

Connections with Music

All examples above can be accessed even without login Facebook account.

More connection types and  examples can be found at Facebook documentation:

http://developers.facebook.com/docs/reference/api/

I will talk more about Facebook Graph API later.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>