Friday, 18 July 2014

Connecting to Twitter's REST API v1.1 with R - Part2

This is in
continuation to my last blog Connecting to
Twitter's REST API v1.1 with R - Part1, where I have already
explained setting up Twitter account to access Twitter APIs from R platform.
Here, we will look into creating handshake between R Studio and Twitter
APIs.

We require few other details from Twitter Application. Open your application and go to Details Tab:

We will use these tokens (Request URL, Authorize URL, Access URL) while creating handshake with Twitter APIs from R.The first and foremost important thing after this is to install R studio or simply R environment from here. I am not going deep into how to install R and other setups. Install Package in R console:To access Twitter APIs from R, you must install few packages in R. Go to R console and write the following code:install.Packages("twitteR"). #This will install other dependent packages like ROAuth, RCurl, and others.Load Packages:library(twitteR). #This will load the package required to access the Twitter APIs. It will load the dependent packages as well.Create Authorization Object:

Copy this Key and paste it in the R console before hitting ENTER button.Next, register this authorization:registerTwitterOAuth(Cred)This completes your authorization process. Now you are ready to go ahead in accessing the twitter APIs.You can access any user's followers count as follows:getUser("<user name>",cainfo="cacert.pem")$friendsCountNow you can start your Data Mining and analysis using twitter data.Thanks for reading my blog. Look forward for my next blog on R.RegardsRocky