在 R Studio for Mac 中设置证书位置时出错



当我尝试使用 R 获取推文时,我遇到了证书错误。我环顾四周,我能找到的只是对于Windows,需要安装rCurl库。我找不到任何适用于 mac 的信息。我尝试了窗户的建议,但找不到任何东西。任何帮助都非常感谢。

    install.packages('twitteR')
    install.packages('plyr')
    install.packages('stringr')
    install.packages('ggplot2')
    library(plyr)
    library(stringr)  
    library(ggplot2)
    library(twitteR)
    requestURL <- "https://api.twitter.com/oauth/request_token"
    accessURL = "http://api.twitter.com/oauth/access_token"
    authURL = "http://api.twitter.com/oauth/authorize"
    consumerKey = "xxxxxxxx"
    consumerSecret = "xxxxxxxx"
    Cred <- OAuthFactory$new(consumerKey=consumerKey,
                     consumerSecret=consumerSecret,
                     requestURL=requestURL,
                     accessURL=accessURL, 
                     authURL=authURL)
    Cred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl") )
    7699317
    registerTwitterOAuth(Cred)
    save(Cred, file="twitter authentication.Rdata")

到目前为止,一切正常。这是我收到错误的地方

     by.list <- searchTwitter('#beyonce', n=1000, cainfo="cacert.pem")  

我收到以下错误:

[1] "设置证书验证位置时出错: CAfile: cacert.pem CApath: none"错误 in twInterfaceObj$doAPICall(cmd, params, "GET", ...) : 错误:设置证书验证位置时出错: CAfile: cacert.pem CA路径:无

我尝试了为Windows建议的以下命令,但在Mac上没有区别。

    library(RCurl)
    options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))

是因为我在Mac上工作吗?还是我的代码有问题?

谢谢!!!

我不得不再次下载CERT文件。R的安装可能具有早期版本。通过添加以下代码,它工作正常。

download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")