OAuth Pin Returns [1]

62 views Asked by At

I've been pulling twitter for about a month now using the following code library (RCurl) library (twitteR) library (streamR) library (ROAuth)

requestURL<-"https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL ="https://api.twitter.com/oauth/authorize"
consumerkey= "my key"
consumersecret = "my secret"
cred <-OAuthFactory$new(consumerKey=consumerkey,consumerSecret=consumersecret,requestURL=requestURL,accessURL=accessURL,authURL=authURL)
cred$handshake (cainfo=system.file("CurlSSL","cacert.pem",package ="RCurl"))

Usually this works, but some times I follow the hyperlink to the pin, paste the pin and get [1] in return. No matter what I write, I just keep getting [1]. Then when I try to submit a request, I'm told it requires OAuth (below). What am I doing wrong? Thank you so much for any help!

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

There are 1 answers

0
aruizga On

If you keep need to do this every time you want the get Twitter data with the streamR package with R. In your code, just add the following:

save(credentials, file="credentials.RData")

This will save your credentials in a file called credentials.RData. Then the only thing you have to do every time you want new Twitter data is load the file doing the following:

library(twitteR)
load("credentials.RData")
registerTwitterOAuth(credentials)

Hope it helps!