`get_liking_users` doesn't work as advertised: only one tweet id is processed
chainsawriot opened this issue · 2 comments
chainsawriot commented
Describe the bug
In the doc of get_liking_users
, it says get_liking_users
"fetches a list of users who liked a tweet or tweets." Because of the way the function is programmed, it can't.
To Reproduce
require(academictwitteR)
#> Loading required package: academictwitteR
require(testthat)
#> Loading required package: testthat
tweet_ids <- c("1387744422729748486", "1400103340495810561", "1399797349296197635", "1400199391961620488")
res <- get_liking_users(x = tweet_ids)
#> Processing 1387744422729748486
#> Total data points: 48
#> This is the last page for 1387744422729748486 : finishing collection.
unique(res$from_id)
#> [1] "1387744422729748486"
testthat::expect_equal(length(unique(res$from_id)), length(tweet_ids))
#> Error: length(unique(res$from_id)) not equal to length(tweet_ids).
#> 1/1 mismatches
#> [1] 1 - 4 == -3
Created on 2021-06-17 by the reprex package (v2.0.0)
It has to do with this break
statement. It breaks the for loop.
chainsawriot commented
It can't flip pages too.
require(academictwitteR)
#> Loading required package: academictwitteR
require(testthat)
#> Loading required package: testthat
res2 <- get_liking_users("1405327120163872777")
#> Processing 1405327120163872777
#> Total data points: 93
#> This is the last page for 1405327120163872777 : finishing collection.
## https://twitter.com/AC360/status/1405327120163872777/likes
## The post has >500 likes.
testthat::expect_gt(nrow(res2), 100)
#> Error: nrow(res2) is not strictly more than 100. Difference: -7
Created on 2021-06-17 by the reprex package (v2.0.0)
chainsawriot commented
Update: the API endpoint GET /2/tweets/:id/liking_users
only returns 100 likers. So, the expected behavior is no page flipping.