search_30day() 403 error?

library(rtweet)
library(tidyverse)

bearer = Sys.getenv("TWEET_BEARER")
auth <- rtweet_app(bearer_token = bearer)
auth_as(auth)

# this has no problem
rt <- search_tweets("#rstats", n = 300, token = auth)

# this returns 403 error
test <- search_30day(q = "#rstats", n = 2000, fromDate = "202210190000", toDate = "202210260000", token = auth, env_name = "rstats")

# returns nothing
auth_sitrep()

things I have tried:
I have twitter dev elevated access. Regenerated my tokens. Still did not work. I did not use auth_setup_default()

If you didn’t save the token it is normal that auth_sitrep() did not print anything, specially if you didn’t use auth_setup_default().

Does the environment name match the one you have for you app? It must match in order of the call to work.
It might also help if you pasted the original error message, maybe I find some clues.
Another issue is that it might be failing because the API was changed to include a new field (the edit history) which current version of rtweet in CRAN doesn’t know how to handle. You could try the devel version from github.

1 Like

Thanks for the swift response!

This is the response when I tried:

Noob question. Is the environment name the same as “app name”? And also which environment should I use? “development”, “staging” or “production”?

You know what. It was mainly because I did not know how to use Twitter Dev.

I had to go to ‘dev environment’ and then assign the search_30day and seach_fullarchive.

now it’s working just fine !!! Thanks rtweet !!!

1 Like