Ste*_*ios 17 twitter ssl r oauth twitter-oauth
我知道有人再问过类似的问题.但是,我已经尝试了我在这里和谷歌上找到的所有东西,似乎没有什么对我有用.
我的代码如下:
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)
Run Code Online (Sandbox Code Playgroud)
我得到:
[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
Run Code Online (Sandbox Code Playgroud)
任何帮助都会非常有用!!
Ton*_*yal 17
首先执行以下操作,然后运行您的代码:
library(RCurl)
# Set SSL certs globally
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))
Run Code Online (Sandbox Code Playgroud)
这通常会纠正您遇到的问题.
编辑(2014年8月): 或者更好的是,尝试使用httr包(这是一个友好的RCurl包装器,为您设置了有用的默认选项)
您可能需要更新 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" ) )
Run Code Online (Sandbox Code Playgroud)
华泰
| 归档时间: |
|
| 查看次数: |
14060 次 |
| 最近记录: |