我正在尝试阅读与寨卡病毒相关的推文,并在Twitter上创建了一个应用程序,但无法通过R连接到Twitter。我尝试过以下命令
reqURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL <- "https://api.twitter.com/oauth/authorize"
consumerKey <- "my consumer key"
consumerSecret <- "my consumer secret key"
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
twitCred$handshake()
在此之后我收到此错误消息:
函数错误(type,msg,asError = TRUE): 无法解析主持人:api.twitter.com
请帮帮我,我已安装以下套餐
library("bitops", lib.loc="~/R/win-library/3.1")
library("digest", lib.loc="~/R/win-library/3.1")
library("RCurl", lib.loc="~/R/win-library/3.1")
library("rjson", lib.loc="~/R/win-library/3.1")
library("ROAuth", lib.loc="~/R/win-library/3.1")
library("twitteR", lib.loc="~/R/win-library/3.1")
答案 0 :(得分:0)
我认为您使用R和Twitter进行身份验证过于复杂。从我读过的几个博客中,您只需拨打setup_twitter_oauth()
一个电话即可,您应该好好去:
consumer_key <- "your_consumer_key"
consumer_secret <- "your_consumer_secret"
access_token <- "your_access_token"
access_secret <- "your_access_secret"
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)
为了获得访问令牌和机密,您必须从Twitter设置页面创建一个Twitter应用程序,并手动生成它们。
请仔细阅读this blog,了解如何执行此操作的分步指南。