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

404 with List Status and List Members #758

Closed cspenn closed 11 months ago

cspenn commented 1 year ago

Problem

When running an API call, I get an error back for the lists_statuses function and the lists_members function.

Error: Twitter API failed [404]. Check error message at https://developer.twitter.com/en/support/twitter-api/error-troubleshooting
* Sorry, that page does not exist. (34)

Expected behavior

Should return tweets.

Reproduce the problem

  tweets <-
    lists_statuses(list_id = 1260956929205112834,
                   verbose = T,
                   retryonratelimit = T)

rtweet version

> packageVersion("rtweet")
[1] ā€˜1.1.0ā€™

Session info

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.0.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] forcats_0.5.2    stringr_1.5.0    dplyr_1.0.10     purrr_1.0.1      readr_2.1.3      tidyr_1.2.1     
 [7] tibble_3.1.8     ggplot2_3.4.0    tidyverse_1.3.2  here_1.0.1       stringi_1.7.12   rtweet_1.1.0    
[13] showtext_0.9-5   showtextdb_3.0   sysfonts_0.8.8   skimr_2.1.5      janitor_2.1.0    lubridate_1.9.0 
[19] timechange_0.2.0 beepr_1.3        pacman_0.5.1    

loaded via a namespace (and not attached):
 [1] httr_1.4.4          jsonlite_1.8.4      foreach_1.5.2       modelr_0.1.10       assertthat_0.2.1   
 [6] askpass_1.1         googlesheets4_1.0.1 cellranger_1.1.0    progress_1.2.2      pillar_1.8.1       
[11] backports_1.4.1     glue_1.6.2          digest_0.6.31       rvest_1.0.3         snakecase_0.11.0   
[16] colorspace_2.0-3    htmltools_0.5.4     pkgconfig_2.0.3     broom_1.0.2         haven_2.5.1        
[21] scales_1.2.1        tzdb_0.3.0          openssl_2.0.5       googledrive_2.0.0   generics_0.1.3     
[26] ellipsis_0.3.2      withr_2.5.0         repr_1.1.5          cli_3.6.0           magrittr_2.0.3     
[31] crayon_1.5.2        readxl_1.4.1        fs_1.5.2            fansi_1.0.3         doParallel_1.0.17  
[36] xml2_1.3.3          tools_4.2.1         prettyunits_1.1.1   hms_1.1.2           gargle_1.2.1       
[41] lifecycle_1.0.3     munsell_0.5.0       reprex_2.0.2        compiler_4.2.1      rlang_1.0.6        
[46] grid_4.2.1          iterators_1.0.14    rstudioapi_0.14     base64enc_0.1-3     gtable_0.3.1       
[51] codetools_0.2-18    DBI_1.1.3           curl_5.0.0          R6_2.5.1            knitr_1.41         
[56] fastmap_1.1.0       utf8_1.2.2          rprojroot_2.0.3     parallel_4.2.1      vctrs_0.5.1        
[61] png_0.1-8           dbplyr_2.3.0        audio_0.1-10        tidyselect_1.2.0    xfun_0.36  
llrs commented 1 year ago

Are you sure that list id exists? Usually I get this error when I try to consult a list that doesn't exists any longer.

cspenn commented 1 year ago

Sure does!

https://twitter.com/i/lists/1260956929205112834

llrs commented 1 year ago

Ok, I can confirm that this time the problem is not the authentication.

It seems that somehow the numeric value is not understood well by R. The number is (silently) converted from 1260956929205112834 to 1260956929205112832:

opt <- options(digits = 22)
id <- 1260956929205112834
id
## 1260956929205112832
options(opt)

You can get request the right list if you quote it:

tweets <- lists_statuses(list_id = "1260956929205112834", verbose = TRUE)

I am not sure how you introduce that number, but perhaps it should change the documentation and only accept characters or I need figure out a way to prevent any "integer precision lost while converting to double" (as as.double(bit64::as.integer64(id)) warns the user)

lfagliano commented 1 year ago

A question on the same topic... is there any way of making list_members ignore the lists that do not work? Similar to what get_timelines does of just popping a message about the page not existing. In list_members the error brakes the process.

llrs commented 1 year ago

@lfagliano I can internally add a tryCatch and provide a warning instead of an error for these cases.

heyitslau commented 1 year ago

Hi! I'm getting the same error when launching get_friends, is there a way to ignore users that do not work and still get the rest of the output? thanks

llrs commented 1 year ago

Hi, @lfagliano and @heyitslau, could you open a different issue with some users where get_friends fails. This way I can test it and we can discuss how to improve that instead of mixing issues here? Thanks

The exact error you get might be important to see if it is the same source and to decide how to fix it (or not).

llrs commented 11 months ago

Closing because I don't think I can do anything about this. I recommend to use characters so id_str instead of the id value returned by the API.