Magnus Metz
Magnus Metz

Reputation: 626

OAUTH issues with twitteR package

I am using R and want to use the twitteR package available on CRAN.

I installed the twitteR package using:

install.packages(twitteR)

then loaded the package with:

library(twitteR)

after that I wanted to run the first command to get the latest trends on twitter with:

getTrends(period="weekly")

which showed following error:

Error in getTrends(period = "weekly") : 
argument "woeid" is missing, with no default

Also the command:

searchTwitter("#orms")

showed an error, namely:

Error in twInterfaceObj$doAPICall(cmd, params, "GET", ...) : 
OAuth authentication is required with Twitter's API v1.1

And also for the command:

userTimeline("informs")

there was an error output:

Error in twInterfaceObj$doAPICall(cmd, params, method, ...) : 
OAuth authentication is required with Twitter's API v1.1

What is the reason for that? From my research so far I figured out, it has something to do with oauth. But actually I don't know, what oauth is, and how to configure it, so I can properly use the twitteR package.

Could please anybody provide me some help for this issue??

Thank you very much in advance for your support.

With best regards!!!

Upvotes: 6

Views: 6520

Answers (1)

lilster
lilster

Reputation: 933

1/ You'll need to load ROAuth, which is a dependency of twitteR. See the twitter CRAN docs. http://cran.r-project.org/web/packages/twitteR/twitteR.pdf

Depends: ... ROAuth (>= 0.9.3) ...

2/ You'll need to authenticate as per the below. See pg12 of the twitteR CRAN docs:

## A real example, but using a fictitious consumerkey and consumer
## secret - you’ll need to supply your own
reqURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "http://api.twitter.com/oauth/access_token"
authURL <- "http://api.twitter.com/oauth/authorize"
consumerKey <- "12345pqrst6789ABCD"
consumerSecret <- "abcd1234EFGH5678ijkl0987MNOP6543qrst21"
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
twitCred$handshake()
registerTwitterOAuth(twitCred)

In general, you should try to search error messages over the CRAN docs of your package - the answer will often be self-contained.

Upvotes: 6

Related Questions