I have a list of usernames on Twitter whose profiles are public. I wish to get "all the tweets" they have posted from the day they formed their profile. I checked Twitter4J examples on GitHub.
According to the Twitter API documentation, only the 20 most recent tweets are returned. Is there anyway I could perform my task?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
To use Twitter4J to get all posts from a user you'll have to make your request over multiple pages..
Below code based of an example on GitHub
Just loop and keep grabbing new pages until there are no new posts should work.
Here is how to get ALL tweets for a user (or at least up to ~3200):
If you read through the Twitter's Documentation, you can retrieve up to 200 tweets at a time if you specify "count=200" in your API request.
You can also use "page=x" to get different paginated results; you could keep doing this until you've retrieved every tweet the user has posted.
I'm not sure how your Java application would create this, but your requests would probably look like:
... etc.
Keep in mind that these requests are rate-limited so you'd need to be careful not to exceed the limit.