Extract And Visualise Facebook Page Data | R Programming

Objective: To Extract the posts data of the "Deadpool Movie" Facebook page

Step 1: Install and load required package


Step 2: Set up OAuth authentification

>my_outh<-fbOAuth(app_id = "123456789", app_secret = "520442aebfdaefcasgjahsdg76c82ad9")

Note: Put your own API ID and API Secret

Step 3: Save and load OAuth

>save(my_outh, file = "my_outh")

Step 4: Test Your OAuth

>me<-getUsers("me", token = my_outh)

Output: "USER NAME"

Step 5: Extract all the page's online activity

>pagedata <- getPage(709487465811929, token = my_outh, n=200)

Step 6: Save as CSV file

>write.csv(pagedata, file = "Marvel recent posts.csv")


You will get following details:

Plot "likes_count" as histogram
>hist(pagedata$likes_count, breaks = 10, col = brewer.pal(3,"Accent"))