Search code examples
twittertwitter4j

Twitter4j - Getting tweets of a particular user in a time interval


I want to get the tweets of an user in a time interval, for example a user's tweets between a 6 months period. I can get all the tweets of a user with getUserTimeline functionality but it seems like it doesn't give me any option about any date interval.

I need something like since and until parameters which is provided by Query class of Twitter4j. I would use that class but it only support searching for keywords. Is there a way to accomplish this?

Thanks in advance.


Solution

  • I don't believe twitter itself provides any date/time related options for getting tweets (aka user timeline statuses).

    If you can extract the tweet ID for the last tweet in that 6 month window, you can set that as max_id and then iterate backwards by setting the lowest tweet ID as max_id till you hit the start of the 6 month window.