我一直在关注多个博客Twitter Authentication with R和Using the R twitteR package的脚本和说明,以访问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 and Windows: register OK, but certificate verify failed和Twitter client for R以及twitteR help unable to authorize even with registering处的类似问题来解决问题
但是,我没有成功解决此问题。非常欢迎任何帮助。提前谢谢。
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
答案 0 :(得分:1)
我遇到了完全相同的问题。
为我修复的是我在https://dev.twitter.com/上的应用设置,并为访问类型选择“读取,写入和访问直接消息” - 您尝试过吗?