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

get_timeline - no applicable method for 'as.integer64' applied to an object of class "list" #148

Closed CCristancho closed 6 years ago

CCristancho commented 6 years ago

Hi, I used the get_timeline succesfully to capture the last 3200 tweets for 300 users a week ago, but now when trying to use it again for 180 users I get the following error:

Error in UseMethod("as.integer64") : no applicable method for 'as.integer64' applied to an object of class "list"

I'm using windows x86_64-w64-mingw32 with R version 3.4.2 (2017-09-28) Thanks!

alexjakubow commented 6 years ago

I'm having this same issue on a Mac running 3.4.1 (2017-06-30)

thoughtfulbloke commented 6 years ago

I'm seeing it as well- in my case it is being generated by a get_favorites() call, to some account name in a long vector of account names (I will try and figure out which)

I have brute forced my way around it by wrapping the get_favorites() in a tryCatch which is returning NULL if it hits an error. Once it has (eventually- there are a few thousand usernames) finished it's run of things it can pick up, I'll find some of the problem entries.

alexjakubow commented 6 years ago

Thanks for the tip. I've adopted your workaround.

thoughtfulbloke commented 6 years ago

I have traced it and in my case the error was triggered by an account which suspended since I got the screen name to reference it, so Twitter is sending back data not expected by rtweet in response to queries.

As Twitter has been getting more active in suspending accounts this could explain people seeing it recently.

mkearney commented 6 years ago

@CCristancho @ajakubow thanks for this. The most recent version of rtweet has dropped use of integer64() and there should be better checks to ensure that an empty data frame and a warning message (i.e., whatever error or 'user not found' message is returned by twitter) is returned. I'm closing this issue for now, but there still may be error conditions that break your code (like @thoughtfulbloke mentioned, Twitter is constantly updating their suspension policies), so please let me know if you run into them so I can work on a fix!

sefabey commented 6 years ago

Not sure if worth reopening this but I am getting the same error with get_followers():

"/1.1/followers/ids.jsonNot authorized.Error in UseMethod("as.integer64") : no applicable method for 'as.integer64' applied to an object of class "list" "

I've been trying to scrape followers of multiple users and been using the get_followers inside purrr::map and getting the same error. It worked once and (luckily) I have managed to scrape followers. Now, I am trying to reproduce in a Rmd but this chunk fails to execute. The chunk code is as follows:

`gf_func2 <- function(x) get_followers(x, n=500000, retryonratelimit = T) #defining function for getting followers from multiple accounts

initial_list_followers <- map_df(initial_patients_list$user_id, gf_func2) %>% distinct()

initial_list_followers`

initial_patients_list is a tibble created by calling lookup_users() on 36 user_ids. I really wish there was a trycatch method that allows code to run because this code takes multiple hours to execute because of Twitter's API limitations and multiple tries get frustrating very quickly.

I am on Mac, R version 3.4.3 and rtweet 0.6.0.

thoughtfulbloke commented 6 years ago

When you say "I really wish there was a trycatch method that allows code to run ", I don't see any obvious reason you can't put get_followers in a tryCatch which returns NULL if there is a problem (or returns something else, but NULL has its advantages IMO)

sefabey commented 6 years ago

TBH, unlike for loops, I do not know how to incorporate tryCatch in map_df.

thoughtfulbloke commented 6 years ago

A couple of of different things there:

# the account assuming_tihis_does_not_exist does not (at time of writing) exist, so
exampledf <- data.frame(user_screen_name = c("thoughtfulnz", "assuming_tihis_does_not_exist"),
                        stringsAsFactors = FALSE)

gf_func2 <- function(x){
  readers <- tryCatch(get_followers(x, retryonratelimit = T), error = function(c) NULL)
  return(readers)
} 
 #defining function for getting followers from 
initial_list_followers <- map_df(exampledf$user_screen_name, gf_func2) %>% distinct()
initial_list_followers
mkearney commented 6 years ago

@sefabey the get_followers bug has finally been fixed! https://github.com/mkearney/rtweet/issues/168