1
我一直在关注来自多个博客Twitter Authentication with R和Using the R twitteR package的脚本和指令以访问twitter API。注册后未经授权访问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
嗨@Stephen,我在Stackoverflow上看到了这个答案。事实上,当我创建一个新应用程序时,问题解决了,但设置没有区别,访问类型设置为“读取,写入和访问直接消息”。无论如何,谢谢你回答希望你的应用程序运行良好。 – MKao