Mining Facebook: Analyzing Fan Pages, Examining Friendships, and More
Exploring Facebook’s Graph API
The Facebook platform is a mature, robust, and welldocumented gateway into what may be the most comprehensive and wellorganized information store ever amassed, both in terms of breadth and depth. It’s broad in that its user base represents about onequarter of the entire world population, and it’s deep with respect to the amount of information that’s known about any one of its particular users. Whereas Twitter features an asymmetric friendship model that is open and predicated on following other users without any particular consent, Facebook’s friendship model is symmetric and requires a mutual agreement between users to gain visibility into one another’s interactions and activities.
Understanding the Graph API
As its name implies, Facebook’s social graph is a massive graph data structure representing social interactions and consisting of nodes and connections between the nodes. The Graph API provides the primary means of interacting with the social graph, and the best way to get acquainted with the API is to spend a few minutes tinkering around with the Graph API Explorer.
It is important to note that the Graph API Explorer is not a particularly special tool of any kind. Aside from being able to prepopulate and debug your access token, it is an ordinary Facebook app that uses the same developer APIs that any other developer application would use. In fact, the Graph API Explorer is handy when you have a particular OAuth token that’s associated with a specific set of authorizations for an application that you are developing and you want to run some queries as part of an exploratory development effort or debug cycle.
Analyzing Social Graph Connections
This package contains a few useful convenience methods that allow you to interact with Facebook in a number of ways. However, there are really just a few key methods from the GraphAPI class (defined in the facebook.py source file) that you need to know about in order to use the Graph API to fetch data, so you could just as easily opt to query over HTTP directly with requests.
ANALYZING THIS BOOK’S FACEBOOK PAGE
Given that this book has a corresponding Facebook page that happened to turn up as the top result in a search for “social web,” Your imagination is the only limitation to what you can ask of the Graph API when mining a Facebook page’s content for insights, and these questions should get you headed in the right direction. Along the way, we’ll also use these questions as the basis for some comparisons among other pages.
VISUALIZING AUDIENCE ENGAGEMENT USING MATPLOTLIB
Now we have the tools needed to measure engagement on a Facebook page’s posts, but we want to be able to compare different pages to each other easily (instead of musicians, you might be looking at how well your company’s page engages its followers, and you’ll want to compare that to competitors in your industry.
The goal of teach you about the Graph API, how the Open Graph protocol can create connections between arbitrary web pages and Facebook’s social graph, and how to programmatically query the social graph to gain insight into Facebook pages and your own social network.