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

1 Answer 1

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)
5
  • 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") ) Mar 10, 2013 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). Mar 10, 2013 at 22:53
  • And don't feel stupid! We all should try to learn more every day. Mar 10, 2013 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! Mar 11, 2013 at 9:26
  • NP. Onwards and upwards. Welcome to SO. :-) Mar 12, 2013 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.