2013-04-23 57 views
0

我在R中使用下面的腳本,但是當我將用戶重定向到oauth的瀏覽器時。並輸入PIN碼,它會打印一個錯誤。請在這種情況下幫助我。謝謝。使用R的Windows ROauth,授權後的無效響應

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() ř版本3.0.0(2013年4月3日) 平臺:x86_64的-W64-的mingw32/64(64位)

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 
+0

我們需要更多的細節。 'sessionInfo()'和* all *您用來授權的代碼。 – 2013-04-23 17:31:24

+0

請看看我的會話信息,其餘代碼完整! – Desire 2013-04-23 18:21:28

回答

2

您在你的代碼中有錯誤的URL。替換httpshttp

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) 

我通常會寫這篇文章的評論,但是這似乎來了很多。

+0

非常感謝好友!我希望你的回答和這個問題將幫助數百人:) – Desire 2013-04-23 18:40:39

相關問題