Get the latest science news and technology news, read tech reviews and more at ABC News. There are plenty of people who enjoy the warm sadness cowboy drink known as whiskey. While some might have a John Wayne instinct to drink it neat, the real. Facebook Data Mining using R. In this tutorial, we will see how to extract and analyze facebook data using R. Facebook has crossed more than 1 billion active users. Facebook has gathered the most extensive data set ever about behavior of human. In R, we can extract data from Facebook and later analyze it. Social media mining is one of the most interesting piece in data science. You can analyze sentiments of an important event by pulling information about the event from Facebook and get insights from data in R. Step by Step Guide : Extract Data from Facebook. Step I : Facebook Developer Registration. Go to https: //developers. Get Started button at the top right of page (See the snapshot below). After it would open a form for registration which you need to fill it to get yourself registered. Step II : Add a new App. Once you are done with registration as shown in step 1, you need to click on My Apps button (check out the snapshot below). Then select Add a New App from the drop down. Then you need to write Display Name of App ID (Type any name) and select drop down option in Category (Choose Education). Create App ID button. Step 3 : Get App ID and App Secret. In this step, we need to note down our App ID and App Secret (Refer the screenshot below). Step 4 : OAuth Settings. On the left hand side menu, click on Add Product Button. Click on Facebook Login link. Under Settings, make sure YES is selected in Client OAuth Login. Type http: //localhost: 1. Valid OAuth redirect URIs box. Click on Save Changes button. If you don't put information correctly, you would get the following error - Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings. Step 5 : Write R Script. Install required packages. Go to R and install Rfacebook and RCurl packages. In “The Assistant Economy,” Dissent Magazine analyzes the privileged and idiosyncratic career path of “personal assistants” who serve a single high-profile.Run the following code to install them. Rfacebook")install. RCurl"). The package Rfacebook lets you to access Facebook App via R. Load desired packages. In this step, we will load the above installed packages. Rfacebook)library(RCurl)3. Paste your app id and app secret below. OAuth(app_id="1. 83xxxxxxxx. TRUE)Press ENTER in R Console or CTRL+ENTER in R Studio. It would return the following message - Copy and paste into Site URL on Facebook App Settings: http: //localhost: 1. When done, press any key to continue.. Waiting for authentication in browser.. Press Esc/Ctrl + C to abort. Check your profile account information. Users("me",token=fb_oauth, private_info=TRUE)me$name[1] "Deepanshu Bhalla"Fix : Error. Are you getting the error below? Error in call. API(query, token) : An active access token must be used to query information about the current user. Recently Facebook has made changes in the API which causes error in functions of Rfacebook package. See the method below to correct it. Step 1 : Run the following program. OAuth < - function(app_id, app_secret, extended_permissions=FALSE, legacy_permissions=FALSE, scope=NULL){## getting callback URLfull_url < - oauth_callback()full_url < - gsub("(.*localhost: [0- 9]{1,5}/).*", x=full_url, replacement="\\1")message < - paste("Copy and paste into Site URL on Facebook App Settings: ",full_url, "\n. When done, press any key to continue..")## prompting user to introduce callback URL in app pageinvisible(readline(message))## a simplified version of the example in httr packagefacebook < - oauth_endpoint(authorize = "https: //www. TRUE){scope < - c("user_birthday", "user_hometown", "user_location", "user_relationships","publish_actions","user_status","user_likes")}else { scope < - c("public_profile", "user_friends")}if (legacy_permissions==TRUE) {scope < - c(scope, "read_stream")}} if (package. Version('httr') < "1. Rfacebook requires httr version 1. Version('httr') < = "0. GET("https: //graph. Authentication successful.")}} ## less early httr versionsif (package. Version('httr') > "0. Version('httr') < = "0. FALSE)if (GET("https: //graph. Authentication successful.")}} ## httr version from 0. Version('httr') > "0. Version('httr') < "1. Sys. setenv("HTTR_SERVER_PORT" = "1. FALSE)if (GET("https: //graph. Authentication successful.")}} ## httr version after 1. Version('httr') > = "1. FALSE)if (GET("https: //graph. Authentication successful.")}} ## identifying API version of tokenerror < - try. Catch(call. API('https: //graph. Step 2 : Run fb. OAuth function again. Make sure you put your own app_id and app_secret number before using the code below. OAuth(app_id="1. 83. TRUE)Now, get. Users() function will work. List of all the pages you have liked.Suppose you want to see all the pages you have liked in the past. Vag Com 311 3 Keygen . Likes(user="me", token = fb_oauth)sample(likes$names, 1. The sample() function is used to list some 1. The Hindu" "ADGPI - Indian Army" "Brain Humor". Jokes Corner" "The New York Times" "Oye! Extra Pen Hai?". [7] "So You Think You Can Dance" "Shankar Tucker" "Rihanna". Lindsey Stirling"6. Update Facebook Status from R. You can also update status in Facebook via R.Status("this is just a test", token=fb_oauth)7.Search Pages that contain a particular keyword. there. Pages( string="trump", token=fb_oauth, n=2. In the above code, we are telling R to search all the pages that contain 'trump' as keyword. The n= 2. 00 refers to the number of pages to return. It returns 1. 6 variables. See the list of variables - [1] "id" "about" "category" [4] "description" "general_info" "likes" [7] "link" "city" "state" [1. Donald J. Trump" "Ivanka Trump". President Donald Trump Fan Club" "President Donald J. Trump". [5] "Donald Trump Is My President" "Donald Trump For President" 8. Extract list of posts from a Facebook page. See the status posted by BBC News. The facebook page name of BBC News is bbcnews. Page(page="bbcnews", token=fb_oauth, n=2. The above image is truncated. It returns in total 1. See the variables' list - [1] "from_id" "from_name" "message" "created_time" [5] "type" "link" "id" "story" [9] "likes_count" "comments_count" "shares_count. Get all the posts from a particular date. You can also put the beginning and end date of the posts you wanted to extract. Page("bbcnews", token=fb_oauth, n=1. Which of these posts got maximum likes? To know the most popular BBCNews post, you can submit the following line of code. Could circular runways take off? BBC World Hacks)"1.Which of these posts got maximum comments?Some posts are not so popular in terms of likes but they fetch max comments.It might be because they are controversial.When Angela Merkel met Donald J.Trump, did her reactions speak louder than words? . Which post was shared the most? Islam will be the world's largest religion by 2. Extract a list of users who liked the maximum liked posts. In terms of marketing or growth of a website, it is very important to know about the users who liked a certain post. Post(summary$id[1], token=fb_oauth, comments = FALSE, n. To view the list of people. Result - . from_name from_id. Tommy Johnson 1. 01. Mirtunjay Raj 3. Sony Joseph 1. 42. Note - I have edited the IDs to maintain privacy. Extract FB comments on a specific post. To know what users think about a post, it is important to analyze their comments. Post(page$id[1], token=fb_oauth, n. FALSE)comments < - post$commentsfix(comments)1. What is the comment that got the most likes? What are the most common first names in the user list? TRUE), n=3). David John Daniel. Extract Reactions for most recent post. Facebook has more than a like button. Last year, it launched emoji (emoticons). If a post got 1k likes, it does not mean everyone really loves the comment. The reaction can be happy, sad or angry. Reactions(post=page$id[1], token=fb_oauth). Get Posts of a particular group. First, search. Group() function searches id of a group from which you want to pull out posts. Later, the group ID is used as a input value in get. Group() function. Extract posts from Machine Learning Facebook groupids < - search. Group(name="machinelearningforum", token=fb_oauth)group < - get. Group(group_id=ids[1,]$id, token=fb_oauth, n=2. In case, search. Group() function could not find group id. You can search it on lookup- id website. End Notes. Text Mining (Social) has gained a lot of interest in a last couple of years.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
October 2017
Categories |