WhatsApp Chat Sentiment Analysis in R

How To Set Up FaceBook OAuth Access Token | R Programming


Objective: How to create Facebook OAuth access token that enables R to make authenticates calls to the Facebook API. This OAth set is essential for the purpose of extracting Facebook data using R Programming.

Step 1: First open Facebook for Developers website [click Here]

Step 2: Log In with your regular Facebook account

Step 3: On the top bar, Click on Get Started


Step 4: Following Box will pop up, click on Create App ID

 

Step 5: Choose a display name as per your convenience and put your FB user email as contact email 

 

Step 6: You will be directed to following page, Note down your APP ID and APP Secret Key, click on the settings tab provided in left side menu bar


Step 7: In Setting Tab click on the ADD PLATFORM button available below the main dialog box and choose website and new tab names WEBSITE will appear with one field as site URL. Paste  http://localhost:1410/ in the field
Step 8: Click on the Tool & Support option available at Top right corner and Choose the first option  Graph API Explorer.

Step 9: Click on Get Token and a box will pop up with various options, Check all the options and click on Get Access Token. Once you are through with this step you will get access token in the field next to Access Token besides Get Token. Note that code.


Step 10: Install and Load Package ‘Rfacebook’ in R
>install.packages("Rfacebook")
>library(Rfacebook)

Step 11: Define APP ID, API Key and Access Token.
>App_id <- YOUR APP ID      #Which you noted down in step 6
>App_secret <- YOUR APP SECRET
>Access_token <- YOUR ACCESS TOKEN      #generated in step 9

Step 12: Set up OAuth in R

>my_oauth <- fbOAuth(app_id = App_id, app_secret = App_secret)
>save(my_oauth, file = "my_oauth")
>load("my_oauth")



Step 13: Check your OAuth Authenticity

>me <- getUsers("me", token = acess_token)
>me$name

If the last command returns your name. You have successfully set up OAuth Access Token in R for Facebook.