[英]How to get Twitter's user's latest tweets in Android
I'm developing a small application that, given a user name, it gets the user tweets. 我正在开发一个小应用程序,根据用户名,它会获得用户推文。 It should check for new tweets regularly.
它应该定期检查新的推文。 The question is how to detect new tweets ?
问题是如何检测新推文?
I use the simple way for getting tweet feed by sending get request on the link 我使用简单的方法通过在链接上发送get请求来获取tweet feed
http://twitter.com/statuses/user_timeline/userName.json ".
http://twitter.com/statuses/user_timeline/userName.json “。
No authentication, no login, no hard stuff (I need your comments also if this method has some disadvatages) 没有身份验证,没有登录,没有硬件(如果这种方法有一些缺点,我也需要你的意见)
Then, I parse the output JSON object and get the tweets. 然后,我解析输出JSON对象并获取推文。
For checking new tweets I'm thinking about comparing the date of the last tweet I get with the tweet feed (eg 5 tweets) until i reach some one with a date less than or equals the last one I have. 为了检查新的推文,我正在考虑将我得到的最后一条推文的日期与推文摘要(例如5条推文)进行比较,直到我找到一个日期小于或等于我的最后一条推文。
So my questions in short are : 所以我的问题很简单:
Is the method I use for getting tweets a good solution or have problems? 我使用的方法是为推文提供一个好的解决方案还是有问题? Is there a better way to get the new tweets rather than the one I suggested ?
是否有更好的方式来获取新推文而不是我建议的推文?
There's a better way. 还有更好的方法。 Take a look at the documentation .
看一下文档 。
You want to use 你想用
since_id
That will get all tweets newer that the ones you have retrieved. 这将使你所检索的所有推文更新。
So, this call gets all my tweets: 所以,这个电话会收到我的所有推文:
https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=edent
My most recent Tweet has ID "224794768041984001" 我最近的推文有ID“224794768041984001”
So, to get all the ones after that, you make this call: 所以,为了得到那之后的所有,你打这个电话:
https://api.twitter.com/1/statuses/user_timeline.json?since_id=224794768041984001&include_entities=true&include_rts=true&screen_name=edent
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.