Reputation: 1133
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 have followed the directions in the twitteR vignette and the other stackoverflow questions concerning the matter (http://stackoverflow.com/questions/8122879/roauth-on-windows-using-r), but none seem to get around this error. Here is the code I am 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)
Through here works. registerTwitterOAuth returns TRUE, so you would think that everything worked. But when I try and send a tweet, I get the error listed above.
I'm trying to send a tweet by doing:
tweet("text to tweet")
This results in:
Error in .self$twFromJSON(out) :
Error: Could not authenticate with OAuth.
Not sure what's going wrong. The OAuth validation seems to work, but then I am unable to send tweets.
Upvotes: 4
Views: 4044
Reputation: 7784
I just updated twitteR
and ROAuth
packages and ran these commands, and everything worked for me:
cred = getTwitterOAuth(consumerKey, consumerSecret)
registerTwitterOAuth(cred)
tweet("something incredibly interesting...")
Seems that twitterR
now provides a cleaner interface to register the OAuth credential, which does not require explicit use of the OAuthFactory$new
or handshake
calls. When I tried explicitly calling these functions, things started to break. But when I used the interface above, everything worked smoothly.
Upvotes: 2
Reputation: 4754
This hopefully was resolved with the version that I just uploaded yesterday. If you're not already using 0.9.1 version of ROAuth, can you update your package and try again?
Upvotes: 3