The graph API allows developers to tap into the ‘social graph’ and retrieve information from Facebook. It can be used to retrieve public information and also, with the appropriate permissions, more personal information, information about your friends, employment – basically anything that you share to the public or explicitly authorise the app or website to access.
The graph API is not just limited to people and their profiles on Facebook. It can also be used to access things such as events, pages and groups. If it is on Facebook, then chances are you can access and retrieve the information using the graph API.
The ‘social graph’ on Facebook contains everything within the ‘Facebook world’ and how it connects and relates to each other. You can get information on who is friends with who, who is attending which events, and who likes a particular celebrity.
Facebook treats all these different types of information as ‘objects’. There are different types of objects but essentially, everything within the world of Facebook is an object and it is assigned its own unique ID which, as the name suggest, uniquely identifies an individual object.
For example, if you are using ColdFusion, then the JSON data returned by Facebook to your website is essentially, to all intents and purposes, as far as ColdFusion is concerned, a long string with delimiters. In ColdFusion, this makes the data hard to work with. It would be easier if it was a structure, with appropriately named attributes. That’s no problem, ColdFusion includes a very handy function called ‘DeserializeJSON’. This function can convert the returned data into an array (structure) of appropriately named attributes ready for you to use and manipulate within your application or website.
An example of the data returned by Facebook from a request to the Graph API is shown below:
“name”: “Facebook Platform”,
“founded”: “May 2007”,
“company_overview”: “Facebook Platform enables anyone to build…”,
“mission”: “To make the web more open and social.”,
“products”: “Facebook Application Programming Interface (API)…”,
(Facebook, no date).
The example above shows the returned public data about the Facebook Platform page. It describes the general attributes and information of the page. This can be used in data on your own website or it can be used in part or whole in your own functions and calculations.
The graph API can be used to access many items including:
- Status Messages
- Photo Albums
- Profile Pictures
The power of the Graph API cannot be overstated – when integrated correctly into a quality third party application, its full power can be realised and your application or website can be instantly taken from being standalone, to fully integrated with the Facebook website (and its many millions of users).