Facebook is very famous, commonly used Social Media today. We can get huge data from here and do Text Mining and Sentiment Analysis.
I also have thought of doing this. 🙂
To create connection between Rstudio and Facebook, user should have :-
1. facebook account
2. registered with Facebook API (click on “register now” option on Facebook Developer)
3. RFacebook package installed in R.
With above 3 prerequisites satisfied, user is ready to generate access token which is required for connection.
There are two ways to get access token:
Type 1: Generate Token from Facebook Graph API Explorer:
1.Go to Facebook Developer , Click on “Tools & Support” then select “Graph API Explorer”
2.Select “Get Token” then “Get User Access Token”
3.Select all fields, then click “Get Access Token”. After this we will get an Access Token. But one thing to notice that, it is temporary token which will last for 2 hrs, after that we need to again click on “Get Token”. Same token will get refreshed
4.Use this token in R as:
See R is connected now.
Type 2: Generate Token from Facebook OAuth (by creating App):
1.Go to Facebook Developer, click on “Add a New App” then Select Website (www)
2.Since we are creating a new App, click on “Skip and Create App ID”, fill App Name, email ID and Category, then click on “Create App ID”
3.Click on Settings -> Basis -> Add Platform, write “http://localhost:1410” in site URL and click on “Save Changes”
4.We can Use App ID and token in R to get it connected to Facebook.
5.Click enter to continue after that it will take you to FB authorization page:
Click okay, and you will get below message on Internet explorer:
Authentication complete. Please close this page and return to R.
And authorization Complete and successful message on R.
You can save the authorization variable for later use:
save(fb_oauth, file=”fb_oauth”)
load(“fb_oauth”)