错误:oauth_listener()需要R中的交互式环境

时间:2015-05-05 07:36:38

标签: r twitter oauth oauth-2.0 twitter-oauth

我正在通过连接到twitter的命令行尝试使用R脚本。当我通过R-Studio运行代码时,它能够连接到Twitter并获取推文。但是,当我通过命令行运行脚本时,我收到以下错误:

pxssh

为了解决这个问题,我通过R-studio运行了一次,并以下列方式保存了环境变量:

Error: oauth_listener() needs an interactive environment.

现在我收到一个错误:

if(file.exists("./token_file"))
  {
    load("./token_file")
  }
  else
  {
     token <- setup_twitter_oauth(consumerKey,consumerSecret,access_token=NULL, access_secret=NULL)
    save(token,file="./token_file")
  }

我尝试通过以下方式保存身份验证会话:

Error in get_oauth_sig() : OAuth has not been registered for this session

但是我仍然遇到上述错误。有没有办法让R通过命令行连接到Twitter?

我正在使用requestURL <- "https://api.twitter.com/oauth/request_token" accessURL <- "https://api.twitter.com/oauth/access_token" authURL <- "https://api.twitter.com/oauth/authorize" if(file.exists("./auth_file")) { load("./auth_file") } else { my_oauth <- OAuthFactory$new(consumerKey = consumerKey, consumerSecret = consumerSecret, requestURL = requestURL, accessURL = accessURL, authURL = authURL) save(my_oauth,file ="./auth_file") } 包。

我使用函数

在twitter中搜索流
twitteR

1 个答案:

答案 0 :(得分:1)

我认为您需要使用与交互式登录不同的身份验证模型。不幸的是,我不是这方面的专家,但似乎从你想要的Twitter文档和#34;仅应用程序身份验证&#34;。

https://dev.twitter.com/oauth/application-only