Question

I am coming across a certificate error when i am trying to fetch tweets using R. I looked around and all i could find is that for windows there is a need to install the rCurl library. I could not find any information for mac. I tried what was suggested for windows but could not find anything. Any help is much appreciated.

    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")

Everything works fine till this point. This is where i get the error

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

I get an error of:

[1] "error setting certificate verify locations:\n CAfile: cacert.pem\n CApath: none\n" Error in twInterfaceObj$doAPICall(cmd, params, "GET", ...) : Error: error setting certificate verify locations: CAfile: cacert.pem CApath: none

I tried the following command suggested for windows but it makes no difference on mac.

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

Is it because i am working on a mac? or is something wrong with my code?

Thanks!!!

Was it helpful?

Solution

I had to download the CERT again. It could be the case that the installation of R had an earlier version. By adding the below code, it worked fine.

download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top