0

I want to connect R to Twitter. I have followed the steps set our here: http://cran.r-project.org/web/packages/twitteR/vignettes/twitteR.pdf

The code that I have is as follows:

library(ROAuth)
cred <- OAuthFactory$new(consumerKey="xyz",
consumerSecret=xyz",
requestURL="https://api.twitter.com/oauth/request_token",
accessURL="https://api.twitter.com/oauth/authorize",
authURL="https://api.twitter.com/oauth/access_token")
cred$handshake(ssl.verifypeer = FALSE)

When I get the twitter link: https://api.twitter.com/oauth/access_token?oauth_token=YZZOYJ1liH1TDEY8G6Eb3YmgAWQlgGiEfAzI1ADwZ4

and load it in my broweser it brings back a blank page with no information on the PIN. Can anyone tell me why this link is blank

Simon O'Hanlon
  • 58,647
  • 14
  • 142
  • 184
user1966593
  • 69
  • 10

1 Answers1

0

Because you are visiting the wrong URL to authroize. Swap your auth and access urls around!

accessURL="https://api.twitter.com/oauth/access_token",
authURL="https://api.twitter.com/oauth/authorize")

#You should get...
Cred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl") )   
To enable the connection, please direct your web browser to: 
http://api.twitter.com/oauth/authorize?oauth_token=someaccessstokenvalue
When complete, record the PIN given to you and provide it here: 

#Final step to register connections
registerTwitterOAuth(Cred)
Simon O'Hanlon
  • 58,647
  • 14
  • 142
  • 184
  • SimonO101, thanks for your help. I feel really stupid but I am trying to get to grips with this R package. Can I ask why you have changed the following code? What is the benefit `Cred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl") ) ` – user1966593 Mar 10 '13 at 20:08
  • No problem! The `cainfo` bit tells the system where to find a particular cacert file supplied with `RCurl`. The `cacert` file contains certificates of public certificate authorities which your system uses to verify that the server called itself Twitter really is who it say it is. Sometimes the default file used with Curl can be out of date and the system can't verify the certificate it receives from the server. (this tends to happen more on Windows systems). – Simon O'Hanlon Mar 10 '13 at 22:53
  • And don't feel stupid! We all should try to learn more every day. – Simon O'Hanlon Mar 10 '13 at 22:54
  • If this answered your question please press the green tick next to my answer so this question can be removed from the unanswered questions stack. Thanks! – Simon O'Hanlon Mar 11 '13 at 09:26
  • NP. Onwards and upwards. Welcome to SO. :-) – Simon O'Hanlon Mar 12 '13 at 10:06