OAUTH issues with twitteR

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

I installed the twitteR package using:

install.packages(twitteR) 

then downloaded the package using

 library(twitteR) 

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

 getTrends(period="weekly") 

which showed the 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 API v1.1 

And also for the team:

 userTimeline("informs") 

error output appeared:

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

What is the reason for this? From my research so far, I have found out that this has something to do with oauth. But in fact, I do not know what oauth is and how to configure it, so I can use the twitteR package correctly.

Can someone help me on this?

Thank you for your support.

Best wishes!!!

+6
source share
1 answer

1 / You will need to download ROAuth, which is a twitteR dependency. See the documentation on Twitter CRAN. http://cran.r-project.org/web/packages/twitteR/twitteR.pdf

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

2 / You need to authenticate as shown below. See Pg12 in 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 find error messages in the CRAN documents of your package - the response will often be self-contained.

+6
source

Source: https://habr.com/ru/post/958226/


All Articles