twitter API fetching tweets after since id

会有一股神秘感。 提交于 2019-12-11 14:45:44

问题


I'm trying to process tweets through twitter4j. As described here https://dev.twitter.com/docs/working-with-timelines, i have sent my first request with only parameter "count" to retrieve first 100 tweets according my criteria. The subsequent requests should have since_id parameter set with the latest tweet id i retrieved from previous call, so that it will return latest tweets after the given since_id. But what i understand here is, when we send since_id, if there are 200 new tweets are available after that id, the latest 100 will be returned, so i'm going to miss the 100 in between. How should i set the request parameters, so that i can retrieve X amount of tweets from the given since_id? I need to retrieve 100 tweets after the last retrieved tweet id from every call.

Thanks.


回答1:


You can retrieve it, check out https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline You have the max_id, since_id and count options that can help you out get the required result. Let's say the last tweet you got has an ID=X. Save the result somewhere so that next time you specify the since_id as X and you get all the tweets that have an ID greater than this one.



来源:https://stackoverflow.com/questions/17514645/twitter-api-fetching-tweets-after-since-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!