Hi,
I follow all the instructions on Obtaining and using access tokens.
This works fine with one token, but says little about how do I handle more than one token?
I have two different purposes and I would like to switch e.g. to twitter_token2
when twitter_token1
runs out of rate limits.
Should I set multiple TWITTER_PATH
locations in the .Renviron
file?
E.g.:
TWITTER_PATH1=/Users/myname/twitter_token.rds
TWITTER_PATH2=/Users/myname/twitter_token2.rds
....
However, rtweet:::twitter_pat()
only seems to look at Sys.getenv("TWITTER_PAT")
, or files like twitter_tokens
etc…
My question is about the best way to set up a routine such as the following:
tmp.limit <- rate_limit(token=NULL, query="followers(ids))
if (tmp.limit$remaining !=0) { <DO STUFF>}
else { <SWITCH TOKEN AND DO OTHER STUFF> }
Is there a way I can implement this in a straightforward way?
Thank you.
Andrea