Skip to content

Instantly share code, notes, and snippets.

@DominikVogel
Created June 25, 2020 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DominikVogel/6ed792bac3d7eb6c22cca8d1ce94ec2d to your computer and use it in GitHub Desktop.
Save DominikVogel/6ed792bac3d7eb6c22cca8d1ce94ec2d to your computer and use it in GitHub Desktop.
Use specific rtweet token / use token with RScript
# rtweet tries to automatically detect a token for the Twitter API
# This fails when you run the script from the command line with RScript
# If you have multiple tokens, this script also helps selecting the right token
# Code inspired by https://github.com/samzipper/SkeeterStream/blob/master/TestLookupUsers.R
# Requirements:
# You need to have set up a token with rtweet
# More info: https://rtweet.info/articles/auth.html
# Assumption token is stored at /home/username/
library(rtweet)
# read in token which was already created
rtoken <- readRDS(file.path(path.expand("~/"),
".rtweet_token.rds"))
# search twitter!
tweets <- search_tweets("@BarackObama",
n = 25,
type = "recent",
include_rts = FALSE,
retryOnRateLimit = TRUE,
token = rtoken)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment