ROauth on Windows using R, Invalid response after authorization

I'm using the below script in R, but when I redirect user to browser for oauth. and enter the PIN, it printing an error. Kindly help me out in this case. Thanks.

cred=OAuthFactory$new(consumerKey="xxxxx",consumerSecret="xxxxx",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(cainfo="cacert.pem");

To enable the connection, please direct your web browser to: 
https://api.twitter.com/oauth/access_token?oauth_token=xxxxxxxxxxxxxxxxxxxx
When complete, record the PIN given to you and provide it here: xxxx

Error in cred$handshake(cainfo = "cacert.pem") :  Invalid response after authorization.  
You likely misentered your PIN, try rerunning this handshake & browser authorization to get a new PIN.

sessionInfo() R version 3.0.0 (2013-04-03) Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] httr_0.2

loaded via a namespace (and not attached):
[1] digest_0.6.3   RCurl_1.95-4.1 stringr_0.6.2  tools_3.0.0   

You have the wrong URLs in your code. Substitute https for http :

requestURL <- "https://api.twitter.com/oauth/request_token"
accessURL = "http://api.twitter.com/oauth/access_token"
authURL = "http://api.twitter.com/oauth/authorize"
consumerKey = "mykey"
consumerSecret = "mysecret"
Cred <- OAuthFactory$new(consumerKey=consumerKey,
                             consumerSecret=consumerSecret,
                             requestURL=requestURL,
                             accessURL=accessURL, 
                             authURL=authURL)
Cred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl") )
registerTwitterOAuth(Cred)

I would normally write this as a comment, but this seems to come up a lot.

链接地址: http://www.djcxy.com/p/77270.html

上一篇: 麻烦在knitr中使用fig.env?

下一篇: Windows上使用R的ROauth,授权后响应无效