There are no doubts that Facebook is the most known social network in the world. With more than 600 million monthly active users [1], its site is the second most visited site on the web, after Google. Facebook’s user base is therefore important for every company that addresses itself to the public in order to test reactions, analyse opinions and try to understand the customer base. This is why Facebook is one of the social networks considered for our application.
Graph API
The Graph API is the core of the Facebook Platform, enabling developers to read and write data to Facebook. All objects – users, posts, comments, images, likes, connections, etc. – are represented as the nodes of a graph. The API provides two ways of browsing objects, depending on their privacy settings
- unauthenticated browsing of the social graph for publicly available information
- authenticated requests for objects which have a higher privacy level
Since our web application’s purpose is to unify what users post on different social networks about different topics, we are mostly interested in being able to query Facebook for the posts that users publish and then to analyse the reactions.
The Graph API is a very simple API that works on a request – response basis, returning a JSON object for each call. The format of a request for searching over public objects is the following:
https://graph.facebook.com/search?q=QUERY&type=OBJECT_TYPE
where the OBJECT_TYPE can be post, user, page, event, group, place or checkin.
For example to browse all public posts that mention University of Southampton, the query should look like:
https://graph.facebook.com/search?q=university%20of%20southampton&type=post
One of the results looks like:
{
"data": [
{
"id": "160003040686019_212151782143338",
"from": {
"name": "Hartley Library",
"category": "Library",
"id": "160003040686019"
},
"message": "We have some new photos of Hartley Library in our main facebook page (http://www.facebook.com/UniSotonLibrary?sk=photos).",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/188016_171854866189717_7800009_n.jpg",
"link": "https://www.facebook.com/UniSotonLibrary",
"name": "University of Southampton Library",
"description": "The Library is a dynamic service, and is continually adding resources and developing services to support the teaching and research of the University.",
"properties": [
{
"name": "Page",
"text": "197 people like this."
}
],
"icon": "http://b.static.ak.fbcdn.net/rsrc.php/v1/yD/r/aS8ecmYRys0.gif",
"type": "link",
"created_time": "2011-03-14T15:32:37+0000",
"updated_time": "2011-03-14T15:32:37+0000"
}
],
"paging": {
"previous": "https://graph.facebook.com/search?q=university+of+southampton&type=post&limit=25&since=1304436757",
"next": "https://graph.facebook.com/search?q=university+of+southampton&type=post&limit=25&until=1304436757"
}
}
Since every object has an ID and the Graph API allows querying the public data of each object, the response can be parsed and more details can be obtained. In case the user would like to query information that is private, he will have to connect with Facebook through our application and then the application can also provide details about private objects.