ROAuth is no longer used in favor of httr? [Twitter API]

I run R Studio on AWS "Ubuntu Server 12.04.2 LTS" and get R Studio through my browser.

When I try to authenticate to the Twitter API using the ROAuth package with code:

 credential<-OAuthFactory$new(consumerKey="xxxxx", consumerSecret="xxxxx", requestURL="https://api.twitter.com/oauth/request_token", accessURL="https://api.twitter.com/oauth/access_token", authURL="https://api.twitter.com/oauth/authorize") credential$handshake() registerTwitterOAuth(credential) 

I get an error after registerTwitterOAuth(credential) saying

  Error in registerTwitterOAuth(credential) : ROAuth is no longer used in favor of httr, please see ?setup_twitter_oauth 

However, I cannot find any further explanation.

+6
source share
4 answers

Apparently the twitteR package was changed just before I posted it, so the new authentication method is

 setup_twitter_oauth(CUSTOMER_KEY, CUSTOMER_SECRET, ACCESS_TOKEN, ACCESS_secret, credentials_file=NULL) 

see https://github.com/geoffjentry/twitteR

+5
source

I am having problems with the setup_twitter_oauth() function. I ran the following code and it worked for me without errors.

 library(RCurl) require(twitteR) library(ROAuth) reqURL <- "https://api.twitter.com/oauth/request_token" accessURL <- "https://api.twitter.com/oauth/access_token" authURL <- "https://api.twitter.com/oauth/authorize" api_Key <- "XXXXXXX" api_Secret <- "XXXXXXXXXXXXXXXXX" twitCred <- OAuthFactory$new(consumerKey=api_key, consumerSecret=api_secret, requestURL=reqURL, accessURL=accessURL, authURL=authURL ) twitCred$handshake() 

EDIT:

It’s just that the problems that I had with my access_token application are sorted out now, now the setup_twitter_oauth function works fine.

Try using the code below to authenticate Twitter with R if your api_key , api_secret , acsess_token , access_token_secret generated without errors.

 api_key = "XXXXXXXXX" // your api_key api_secret = "XXXXXXXXXX" // your api_secret access_token = "XXXXXXXXXX" // your access_token access_token_secret = "XXXXXXXXXX" // your access_token_sceret setup_twitter_oauth(api_key,api_secret,access_token, access_token_secret) 
+1
source

The following worked for me:

 packages <- c("twitteR","ROAuth")#"openssl","base64enc" ### checking if packages are already installed and installing if not check.install.load.Package<-function(package_name){ if(!package_name%in%installed.packages()){ install.packages(package_name) } library(package_name,character.only = TRUE) } for(package in packages){ check.install.load.Package(package) } api_key = "XX" # your api_key api_secret = "XX" # your api_secret access_token = "XX" # your access_token access_token_secret = "XX" # your access_token_sceret credential<-OAuthFactory$new(consumerKey=api_key, consumerSecret=api_secret, requestURL="https://api.twitter.com/oauth/request_token", accessURL="https://api.twitter.com/oauth/access_token", authURL="https://api.twitter.com/oauth/authorize") credential$handshake() setup_twitter_oauth(api_key,api_secret,access_token, access_token_secret) search.string <- "#RohingyaTerrorReality" no.of.tweets <- 60 RohingyaTerrorReality.Tweets <- searchTwitter(search.string, n=no.of.tweets,lang="en",) df <- do.call("rbind", lapply(RohingyaTerrorReality.Tweets, as.data.frame)) View(df) 
+1
source

I'm having trouble using the setup_twitter_oauth function. I am running the following code and not getting the object after running the setup_twitter_oauth function or the loaded credential file.

Then I just upload the cred_1.RData file and I get sig objetc, which doesn't seem to be useful.

I am on windows and installed the github package version.

 rm(list = ls(,all=T)) setwd("D:\\TWEETS\\cuenta_1") library(twitteR) library(httr) # Credenciales consumer_key = "xxxxxxxxxxxxxxxx" consumer_secret = "xxxxxxxxxxxxxxxx" access_token = "xxxxxxxxxxxxxxxxxxx" access_secret = "xxxxxxxxxxxxxxxx" credentials_file = "cred_1.RData" setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret, credentials_file) load_twitter_oauth("cred_1.RData") ls() > ls() [1] "access_secret" "access_token" "consumer_key" "consumer_secret" [5] "credentials_file" > load("cred_1.RData") > > ls() [1] "access_secret" "access_token" "consumer_key" "consumer_secret" "credentials_file" "load_twitter_oauth" "set_oauth_sig" [8] "sig" > > print(sig) Config: List of 1 $ signature:function (method, url) 
0
source

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


All Articles