The document outlines Victor Gau's lightning talk on accessing the social graph using R. It discusses the social graph and Graph API, explains what JSON is and how to parse it in R. It provides examples of using the Graph API to retrieve public profile data for Facebook pages and accounts. The talk also covers how to access the social graph directly from R using the RCurl and rjson packages and recommends the Facebook Developer Tools for exploring the Graph API and retrieving access tokens.
2. Outline
What is the Social Graph?
Graph API Explained
What is JSON?
“R” to Parse JSON
Spider Revisited
“R” to Access the Social Graph
Using Facebook Developer Tools
Topics for Sharing Next Time
3. What is the Social Graph?
Business Insider: So What The Heck Is The 'Social Graph'
Facebook Keeps Talking About?
4. Graph API Explained
APIs for accessing social graph
HTTP requests are sent to access the social
graph (the responses are in JSON format)
most requests are sent to
https://graph.facebook.com
requests for videos are sent to https://graph-
video.facebook.com
https://developers.facebook.com/docs/gr
aph-api/quickstart/v2.0
10. Spider Revisited
# Load Required Packages
library(RCurl)
library(XML)
# Get Page Source
html = getURL("http://www.ptt.cc/bbs/R_Language/index.html")
# Parse to get information using XPath
xml = htmlParse(html)
Xpath = "//div[@class='title']/a//text()"
titles = xml [Xpath]
11. “R” to Access the Social Graph
# Load Required Packages
library(RCurl)
library(rjson)
# Retrieve Data (in JSON format)
data = getURL("https://graph.facebook.com/htc",
ssl.verifypeer = FALSE )
# Read JSON
htc <- fromJSON(data)
12. “R” to Access Social Graph
Access Token would be needed for
certain content in social graph most of
the time.
Access Token can be retrieved by using
graph explorer from Facebook
Developer Tools.
Sample URL for retrieving information
with Access Token:
http://graph.facebook.com/me/friends?acce
ss_token=XDFAFDFXXXXXXXDAFDA