简体   繁体   English

如何在 rstudio.cloud 上使用 rtweet?

[英]How to use rtweet on rstudio.cloud?

I want to authenticate with Twitter (Rtweet package) via rstudio.cloud.我想通过 rstudio.cloud 使用 Twitter(Rtweet 包)进行身份验证。 The problem is that the authentication opens a new page each time where I am supposed to authorise via Twitter. When I am redirected back from there, I end up in nirvana.问题是每次我应该通过 Twitter 授权时,身份验证都会打开一个新页面。当我从那里重定向回来时,我最终进入了必杀技。

library (rtweet)
> search_users("#ICForumCH", n = 10)
Requesting token on behalf of user...
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort

-> Twitter authentication Page -> -> Twitter 认证页面 ->

Hmmm… can't reach this page
127.0.0.1 refused to connect.

I found this solution from community.rstudio.com but cannot seem to make it work.我从 community.rstudio.com 找到了这个解决方案,但似乎无法使其工作。

Oh, and please don't tell me I need a desktop version.哦,请不要告诉我我需要桌面版。 I will never get the necessary permissions at my workplace.我永远不会在我的工作场所获得必要的许可。

If You have The twitter account logged in your default browser this may work for you.如果您在默认浏览器中登录了 twitter 帐户,这可能适合您。

Run this code first,首先运行这段代码,

library(rtweet)
auth_setup_default()
# Using default authentication available.
# Reading auth from 'C:\Users\XXX\AppData\Roaming/R/config/R/rtweet/default.rds'

You can take default.rds file and upload it to your RStudio.cloud folder.您可以将default.rds文件上传到您的RStudio.cloud文件夹。

Just use只需使用

auth_as("foldername/default.rds")

before post a tweet.在发布推文之前。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM