2013-09-30 41 views
1

我一直在關注來自多個博客Twitter Authentication with RUsing the R twitteR package的腳本和指令以訪問twitter API。註冊後未經授權訪問twitteR API

library(twitteR) 
library(ROAuth) 

reqURL <- "https://api.twitter.com/oauth/request_token" 
accessURL <- "http://api.twitter.com/oauth/access_token" 
authURL <- "http://api.twitter.com/oauth/authorize" 
consumerKey <- "-----------------" 
consumerSecret <- "-----------------------------" 
twitCred <- OAuthFactory$new(consumerKey=consumerKey, 
          consumerSecret=consumerSecret, 
          requestURL=reqURL, 
          accessURL=accessURL, 
          authURL=authURL) 
download.file(url="http://curl.haxx.se/ca/cacert.pem", 
       destfile="cacert.pem") 
twitCred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", 
        package = "RCurl")) 
registerTwitterOAuth(twitCred) 
testSearch = searchTwitter("#food", n = 10, cainfo="cacert.pem") 

我沒有問題登記,一切正常,直到我開始使用searchTwitter()函數,它拋出我下面的錯誤。

testSearch = searchTwitter("#food", n = 10, cainfo="cacert.pem") 
[1] "Unauthorized" 
Error in twInterfaceObj$doAPICall(cmd, params, "GET", ...) : 
    Error: Unauthorized 

我試圖通過看TwitteR, ROAuth and Windows: register OK, but certificate verify failedTwitter client for R和類似的問題在twitteR help unable to authorize even with registering

然而,爲了解決這個問題,我是不成功的,以解決此問題。任何幫助是非常受歡迎的。提前致謝。

R version 3.0.2 (2013-09-25) 
Platform: x86_64-pc-linux-gnu (64-bit) 

locale: 
    [1] LC_CTYPE=en_AU.UTF-8  LC_NUMERIC=C    
    [3] LC_TIME=en_US.UTF-8  LC_COLLATE=en_AU.UTF-8  
    [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_AU.UTF-8 
    [7] LC_PAPER=en_US.UTF-8  LC_NAME=C     
    [9] LC_ADDRESS=C    LC_TELEPHONE=C    
    [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C  

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

other attached packages: 
[1] twitteR_1.1.7 rjson_0.2.13 ROAuth_0.9.3 digest_0.6.3 RCurl_1.95-4.1 
[6] bitops_1.0-6 

loaded via a namespace (and not attached): 
[1] compiler_3.0.2 tools_3.0.2 

回答

1

我遇到了完全相同的問題。

什麼修復了我在https://dev.twitter.com/上的應用設置,並選擇「讀取,寫入和訪問直接消息」訪問類型 - 你試過嗎?

+0

嗨@Stephen,我在Stackoverflow上看到了這個答案。事實上,當我創建一個新應用程序時,問題解決了,但設置沒有區別,訪問類型設置爲「讀取,寫入和訪問直接消息」。無論如何,謝謝你回答希望你的應用程序運行良好。 – MKao