2013-03-11 4 views
17

So che domande simili sono state poste di nuovo. Tuttavia, ho provato tutto ciò che ho trovato qui e su Google e nulla sembra funzionare per me.Certificato SSL non riuscito per twitteR in R

Il mio codice è il seguente:

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) 

Qui ottengo: [1] TRUE

Ma se provo questo: tweets = searchTwitter('blabla', n=1500)

ottengo il seguente errore: [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

Ecco i pacchetti e i versi ons sul mio PC:

sessionInfo() R version 2.15.1 (2012-06-22) Platform: i386-pc-mingw32/i386 (32-bit)

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 

Qualsiasi aiuto sarebbe molto utile !!

+0

Eventuali duplicati: http://stackoverflow.com/q/9916283/1036500 (non ho potuto farlo funzionare o ...) – Ben

+0

Giusto per aggiungere un po 'di paranoia: non tutti i L'errore del certificato SSL è un errore di programmazione, alcuni di questi sono attacchi effettivi (ad esempio, il tuo datore di lavoro, il governo o altri soggetti terzi che sostituiscono un certificato non valido). Twitter funziona correttamente con Google Chrome? – themel

+0

Sì, perché non dovrebbe? – Stergios

risposta

1

Potrebbe essere necessario aggiornare il file cacert.pem. Vedi here e here per collegamenti ad altre domande su questo. Vedo che questo non ha funzionato per altre persone usando download.file(), ma questo potrebbe utilizzare direttamente Curl. È possibile aggiornare il file pacchetto in questo modo:

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

+0

Grazie a Simon, ma non sembra funzionare per me. Perché così tante persone hanno lo stesso problema con l'API di Twitter? Qualcos'altro che potrei provare? – Stergios

17

Procedere come segue prima, e poi eseguire il codice:

library(RCurl) 

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

Questo di solito corregge il problema riscontrato.

EDIT (agosto 2014):O meglio ancora, cercare di usare il pacchetto HTTR invece (che è un wrapper amichevole di RCurl con le opzioni predefinite utili fissati per voi)

2

finalmente ho ottenuto la soluzione , per favore prova questo metodo questo è molto facile

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)