17

同様の質問が再び寄せられていることは承知しています。ただし、こことグーグルで見つけたすべてを試しましたが、何もうまくいかないようです。

私のコードは次のとおりです。

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

ここで私は得る: [1] TRUE

しかし、私がこれを試してみると: tweets = searchTwitter('blabla', n=1500)

次のエラーが表示されます。 [1] "SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed" Error in twInterfaceObj$doAPICall(cmd, params, "GET", ...) : Error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

私のPCのパッケージとバージョンは次のとおりです。

sessionInfo() R バージョン 2.15.1 (2012-06-22) プラットフォーム: i386-pc-mingw32/i386 (32 ビット)

locale:
[1] LC_COLLATE=Greek_Greece.1253  LC_CTYPE=Greek_Greece.1253   
[3] LC_MONETARY=Greek_Greece.1253 LC_NUMERIC=C                 
[5] LC_TIME=Greek_Greece.1253    

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

other attached packages:
[1] ROAuth_0.9.2   digest_0.6.2   twitteR_1.1.0  rjson_0.2.12  
[5] RCurl_1.95-4.1 bitops_1.0-5  

loaded via a namespace (and not attached):
[1] tools_2.15.1

どんな助けでも本当に役に立ちます!!

4

3 に答える 3

18

最初に以下を実行してから、コードを実行します。

library(RCurl) 

# Set SSL certs globally
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))

これにより、通常、発生していた問題が修正されます。

EDIT(2014年8月): または、代わりにhttrパッケージを使用してみてください(これは、便利なデフォルトオプションが設定されたRCurlのフレンドリーなラッパーです)

于 2013-05-08T09:59:12.853 に答える
2

やっと解決したので、この方法を試してみてください。これはとても簡単です

library(devtools)
install_github("twitteR", username="geoffjentry")
library(twitteR)

api_key = "aaa"
api_secret = "bbb"
access_token = "ccc"
access_token_secret = "ddd"
setup_twitter_oauth(api_key,api_secret,access_token,access_token_secret)
于 2014-07-17T21:35:44.490 に答える
1

cacert.pem ファイルの更新が必要になる場合があります。これに関する他の質問へのリンクについては、こちらこちらを参照してください。これは を使用している他の人には機能していないようですdownload.file()が、これは Curl を直接使用している可能性があります。次のようにバンドル ファイルを更新できます。

system( paste0( "curl http://curl.haxx.se/ca/cacert.pem -o " , tempdir() , "/cacert.pem" ) )
#Then you can use it like so
twitCred$handshake( cainfo = paste0( tempdir() , "/cacert.pem" ) )

HTH

于 2013-03-11T20:59:53.797 に答える