TwitteR and ROAuth

I am currently trying to send tweets from R, but I cannot get around the following error:

Error in .self$twFromJSON(out) : Error: Could not authenticate with OAuth. 

I followed twitteR quiz directions and other stackoverflow related questions on this (http://stackoverflow.com/questions/8122879/roauth-on-windows-using-r), but no one seems to get around this error . Here is the code I'm using:

 library("twitteR") library('ROAuth') requestURL <- "https://api.twitter.com/oauth/request_token" accessURL = "http://api.twitter.com/oauth/access_token" authURL = "http://api.twitter.com/oauth/authorize" consumerKey = "*****************************" consumerSecret = "************************" Cred <- OAuthFactory$new(consumerKey=consumerKey, consumerSecret=consumerSecret, requestURL=requestURL, accessURL=accessURL, authURL=authURL) Cred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")) registerTwitterOAuth(Cred) 

It works here. registerTwitterOAuth returns TRUE, so you think everything worked. But when I try to send a tweet, I get the error mentioned above.

I am trying to send a tweeter by doing:

 tweet("text to tweet") 

This leads to:

 Error in .self$twFromJSON(out) : Error: Could not authenticate with OAuth. 

Not sure what will go wrong. OAuth validation seems to work, but then I can not send tweets.

+4
source share
2 answers

This hopefully was resolved with the version I just downloaded yesterday. If you are not using ROAuth 0.9.1 yet, can you update your package and try again?

+3
source

I just updated the twitteR and ROAuth packages and ROAuth these commands and it worked for me:

 cred = getTwitterOAuth(consumerKey, consumerSecret) registerTwitterOAuth(cred) tweet("something incredibly interesting...") 

It seems that twitterR now provides a cleaner interface for registering OAuth credentials, which does not require explicit use of OAuthFactory$new or handshake calls. When I tried to explicitly call these functions, things started to break. But when I used the interface above, everything worked smoothly.

+2
source

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


All Articles