我一直在关注几个博客Twitter Authentication with R和Using the R twitteR package to access the twitter API 中的脚本和指令。
library(twitteR)
library(ROAuth)
reqURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "http://api.twitter.com/oauth/access_token"
authURL <- "http://api.twitter.com/oauth/authorize"
consumerKey <- "-----------------"
consumerSecret <- "-----------------------------"
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
download.file(url="http://curl.haxx.se/ca/cacert.pem",
destfile="cacert.pem")
twitCred$handshake(cainfo = system.file("CurlSSL", "cacert.pem",
package = "RCurl"))
registerTwitterOAuth(twitCred)
testSearch = searchTwitter("#food", n = 10, cainfo="cacert.pem")
我注册没有问题,一切都很好,直到我开始使用 searchTwitter() 函数,它抛出了以下错误。
testSearch = searchTwitter("#food", n = 10, cainfo="cacert.pem")
[1] "Unauthorized"
Error in twInterfaceObj$doAPICall(cmd, params, "GET", ...) :
Error: Unauthorized
我试图通过查看TwitteR、ROAuth 和 Windows 来解决该问题:注册正常,但证书验证失败,R 的 Twitter 客户端和 twitteR 上的类似问题帮助即使注册也无法授权
但是,我没有成功解决这个问题。非常欢迎任何帮助。提前致谢。
R version 3.0.2 (2013-09-25)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_AU.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_AU.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] twitteR_1.1.7 rjson_0.2.13 ROAuth_0.9.3 digest_0.6.3 RCurl_1.95-4.1
[6] bitops_1.0-6
loaded via a namespace (and not attached):
[1] compiler_3.0.2 tools_3.0.2