I'm revising my original query to ask specifically if anyone can see a reason that the R-code I give below would, in of itself, lead to an invalid request token. If not, I'll know my issue lies elsewhere.
I’m trying to use the twitteR package as I’ve gotten to the Twitter chapter in Jeffrey Stanton’s free e-book on Data science which is helping me learn R. I get so far and then Twitter gives me this message:
Whoa there! The request token for this page is invalid. It may have already been used, or expired because it is too old. Please go back to the site or application that sent you here and try again; it was probably just a mistake.
I’ve got the bitops, RCurl, RJSONIO, twitter and ROAuth packages installed. I then run this code(NB I can't post links because my reputation is too low):
reqURL <- "//api.twitter.com/oauth/request_token"
accessURL <- "//api.twitter.com/oauth/access_token"
authURL <- "//api.twitter.com/oauth/authorize"
consumerKey <- "abc"
consumerSecret <- "xyz"
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
Followed by this:
twitCred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl") )
I then get this prompt:
To enable the connection, please direct your web browser to: http://api.twitter.com/oauth/authorize?oauth_token=Kxa... When complete, record the PIN given to you and provide it here:
At this point I can’t seem to copy the twitter link, so I hand type it(!) into my browser and I get the message from Twitter I started my question with. I’ve tried a number of times with the same outcome. The OAuth bit in the TwitteR vignette on r-project doesn’t have anything on this (it assumes I’d have done it right I suppose!) and the example on page nine of the TwitteR package description doesn’t help me either.
Thanks.