ropensci / rtweet

🐦 R client for interacting with Twitter's [stream and REST] APIs
https://docs.ropensci.org/rtweet
Other
785 stars 201 forks source link

rweet not working with new paid Basic Twitter API v2 app, asking for elevated access #772

Closed WahiduzzamanKhan closed 1 year ago

WahiduzzamanKhan commented 1 year ago

Problem

I have a paid Basic Twitter API v2 developer app (the $100 USD/month one). I am trying to use it with {{rtweet}}. Specifically, I am trying to use the search_tweets function. but every time I try to use it I get the following error:

Error: Twitter API failed [403]. Check error message at https://developer.twitter.com/en/support/twitter-api/error-troubleshooting 
 * You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you’ll need to apply for Elevated access via the Developer Portal. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve (453)

As far as I understand elevated access is not a thing anymore and on the developer portal it says "Your Project has Basic access".

I have tried the https://api.twitter.com/2/tweets/search/recent endpoint from Postman, authenticated with the same bearer token and it worked without any problem. Not sure why it is not working with {{rtweet}}

Reproduce the problem

library(rtweet)

token <- rtweet_app("MY_BEARER_TOKEN")

tweets <- search_tweets(q = "#rstats", type = "recent", include_rts = FALSE, token = token)

rtweet version

[1] ‘1.2.0.9003’

Session info

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rtweet_1.2.0.9003

loaded via a namespace (and not attached):
 [1] prettyunits_1.1.1 crayon_1.5.2      withr_2.5.0       R6_2.5.1          lifecycle_1.0.3   jsonlite_1.8.4    httr_1.4.5       
 [8] rlang_1.1.0       progress_1.2.2    cli_3.6.0         curl_5.0.0        rstudioapi_0.14   vctrs_0.6.1       tools_4.2.2      
[15] hms_1.1.3         compiler_4.2.2    pkgconfig_2.0.3  
llrs commented 1 year ago

The search_tweet function only works for the API v1. To search tweets using the API v2 you need to use tweet_search* functions (probably tweet_search_recent).

Congratulations on being the first user who is subscribed and (I know is) using rtweet. Let me tell you I cannot test rtweet on the basic plan because developers do not have discounts or access to it and I don't use rtweet as much as to justify such expensive monthly plan. I have set up a buy me a coffee if you want to help me support for the paid plans.