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

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)
  • 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 9:26
  • Thanks Simon, I am learning all the time :-) – user1966593 Mar 12 '13 at 10:03

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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