twitter API自id以来获取推文 [英] twitter API fetching tweets after since id

查看:534
本文介绍了twitter API自id以来获取推文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图通过twitter4j处理推文。如此处所述 https://dev.twitter.com/docs/working-with-timelines ,我已经发送了我的第一个请求,只有参数count,根据我的标准检索前100条推文。后续请求应该使用从上一次调用中检索到的最新tweet id设置的since_id参数,以便它在给定的since_id之后返回最新的推文。但我在这里理解的是,当我们发送since_id时,如果在该id之后有200条新推文可用,那么最新的100将被返回,所以我将错过100之间。我应该如何设置请求参数,以便我可以从给定的since_id中检索X量的推文?我需要在每次调用最后一次检索的推文ID后检索100条推文。

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.

谢谢。

推荐答案

您可以检索它,查看 https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
你有max_id,since_id并计算可以帮助您获得所需结果的选项。
假设你得到的最后一条推文有一个ID = X.将结果保存在某处,以便下次将since_id指定为X时,您将获得ID大于此值的所有推文。

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.

这篇关于twitter API自id以来获取推文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆