ropensci-archive/rtweet

Error posting on Twitter with media attached (rtweet v. 1.2)

Closed this issue · 1 comments

Problem

Error message when including media in posts

Expected behavior

Expected behavior is a successfully posted Tweet with media included.

Reproduce the problem

Using rTweet 1.2, I can post text successfully to Twitter. The moment I include any form of media, I get:
"Error: Media and alt_text must be character vectors."

I tested with different files (all png) also attempted to add specifically media_alt_text = NULL, but no difference.

library(rtweet)
tweet.text = "Hello world"
media = "C.png" # this file exists in my working directory, and it's a png file of ~ 300 KB

> post_tweet(tweet.text)
Your tweet has been posted!
> post_tweet(tweet.text, media = media)
Error: Media and alt_text must be character vectors.

rtweet version

## copy/paste output
> packageVersion("rtweet")
[1] ‘1.2.0

Session info

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.6.4

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/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] COVID19_3.0.3      gmailr_1.0.1       tm_0.7-8           NLP_0.2-1          tis_1.39           rtweet_1.2.0       jsonlite_1.8.4     httr_1.4.5         lubridate_1.9.2   
[10] forecast_8.21      dplyr_1.1.1        quantmod_0.4.20    TTR_0.24.3         xts_0.13.0         zoo_1.8-11         reshape_0.8.9      RColorBrewer_1.1-3 fredr_2.1.0       

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10       lattice_0.20-45   prettyunits_1.1.1 lmtest_0.9-40     utf8_1.2.3        mime_0.12         slam_0.1-50       R6_2.5.1          plyr_1.8.8       
[10] ggplot2_3.4.1     pillar_1.9.0      rlang_1.1.0       progress_1.2.2    curl_5.0.0        rstudioapi_0.14   data.table_1.14.8 fracdiff_1.5-2    bit_4.0.5        
[19] munsell_0.5.0     compiler_4.2.2    pkgconfig_2.0.3   askpass_1.1       base64enc_0.1-3   urca_1.3-3        nnet_7.3-18       openssl_2.0.6     tidyselect_1.2.0 
[28] tibble_3.2.1      quadprog_1.5-8    fansi_1.0.4       crayon_1.5.2      withr_2.5.0       rappdirs_0.3.3    grid_4.2.2        nlme_3.1-162      gtable_0.3.3     
[37] lifecycle_1.0.3   magrittr_2.0.3    scales_1.2.1      cli_3.6.1         fs_1.6.1          tseries_0.10-53   timeDate_4022.108 xml2_1.3.3        generics_0.1.3   
[46] vctrs_0.6.1       tools_4.2.2       bit64_4.0.5       glue_1.6.2        hms_1.1.3         parallel_4.2.2    timechange_0.2.0  colorspace_2.1-0  gargle_1.3.0     
llrs commented

This is required by rtweet since version 1.0.0 (released on 2022-07-21). Please read this blog post explaining why.

To avoid this error you must provide something like:

post_tweet(tweet.text, media = media, alt_text = "My awesome image about cats, showing my cat with a thread in the garden").