Accessing Facebook data

Lets see how to get the facebook news feed from R. Rfacebook and httpuv package comes handy for this purpose

How To Create App In Facebook ?

Go to Facebook’s developer page

png;base6445692c7eb511caf4

Login and goto Apps->Add new app.

Choose platform as ‘Website’
How To Access Facebook Data

Get app_id and app_secret from  your app’s page. Enter “http://localhost:1410/” in  your facebook app page: Settings–>Site URL

Create credential object
oauth = fbOAuth(app_id,app_secret) 
This will open up a browser page and prompt you to login into Facebook
Once thats done you can start extracting data from Facebook.

USEFUL FUNCTIONS IN Rfacebook

getNewsfeed(oauth,no of feeds) # to get news feed
getFriends(oauth,simplify=FALSE) #to get  user friends

ACCESS FACEBOOK DATA USING GRAPH API

You can also directly access facebook data using their graph API

You can choose to either use the token object created earlier or use a  temporary access token (expires after 2 hours) generated at Facebook Graph API

graph

In case you are using the temporary access  token then

oauth=sign_oauth2.0(“access token”)

To retrieve data you have to use GET https  requests to graph.facebook.com

GET(url="https://graph.facebook.com//me?", config(token=outh)) #get user information in a JSON object

If you like us, please tell your friends.Share on LinkedInShare on Google+Share on RedditTweet about this on TwitterShare on Facebook