1

Attached code works fine for me when manually running it after restarting windows and R - but not when scheduling the task with taskscheduleR package (stops immediately after it starts running, creates file but no content). Might be related to some access-token-issues but I couldn't solve it.

Any ideas...?

##Before restart (manually)...
  library("rtweet")
  appname <- "herr[...]mann"
  key <- "SzA[...]1o7u"
  secret <- "4MtSJom[...]WjdgRUuz"
  twitter_token <- create_token(app = appname, consumer_key = key, 
                                consumer_secret = secret)
  saveRDS(twitter_token, file = "C:/Users/DataMine/Documents/R/twitter_token.rds")

##After restart (scheduled)...
  library("rtweet")
  twitter_token <- readRDS("C:/Users/DataMine/Documents/R/twitter_token.rds")
  test <- stream_tweets(q = "election", file_name = "...", timeout = 60)
TylerH
  • 20,799
  • 66
  • 75
  • 101
Robert
  • 133
  • 10

1 Answers1

1

Access-token needs to be handed over manually to the token argument...:

twitter_token <- readRDS("C:/Users/DataMine/Documents/R/twitter_token.rds")
stream_tweets(q = "ellection", token = twitter_token)

For me, that was the only way to get this thing on schedule (taskscheduleR)...

Robert
  • 133
  • 10