我正在尝试在 R 中挖掘 twitter 数据,但开始时遇到了麻烦。我创建了一个 twitter 帐户,一个 twitter 开发人员中的应用程序,将设置更改为读取、写入和访问,创建了我的访问令牌,并按照说明注册它:
我的代码:
> library(twitteR)
> download.file(url="http://curl.haxx.se/ca/cacert.pem",
+ destfile="cacert.pem")
> requestURL <- "https://api.twitter.com/oauth/request_token"
> accessURL <- "https://api.twitter.com/oauth/access_token"
> authURL <- "https://api.twitter.com/oauth/authorize"
> consumerKey <-"my key" #took this part out for privacy's sake
> consumerSecret <- "my secret" #this too
> twitCred <- OAuthFactory$new(consumerKey=consumerKey, consumerSecret = consumerSecret, requestURL = requestURL, accessURL = accessURL, authURL = authURL)
> twitCred$handshake(cainfo="cacert.pem")
To enable the connection, please direct your web browser to:
https://api.twitter.com/oauth/authorize?oauth_token=zxgHXJkYAB3wQ2IVAeyJjeyid7WK6EGPfouGmlx1c
When complete, record the PIN given to you and provide it here: 0010819
> registerTwitterOAuth(twitCred)
[1] TRUE
> save(list="twitCred", file="twitteR_credentials")
然而,这个:
> s <- searchTwitter('#United', cainfo="cacert.pem")
[1] "Unauthorized"
Error in twInterfaceObj$doAPICall(cmd, params, "GET", ...) :
Error: Unauthorized
我快要发脾气了。如果有人可以向我解释出了什么问题,或者更好的是如何解决它,我将非常感激。
谢谢你。