如何在Android中获取Twitter用户的最新推文 [英] How to get Twitter's user's latest tweets in Android

查看:64
本文介绍了如何在Android中获取Twitter用户的最新推文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个小应用程序,给定一个用户名,它会获取用户的推文.它应该定期检查新推文.问题是如何检测新推文?

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

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)

然后,我解析输出的 JSON 对象并获取推文.

Then, I parse the output JSON object and get the tweets.

为了检查新推文,我正在考虑将我收到的最后一条推文的日期与推文提要(例如 5 条推文)的日期进行比较,直到我找到某个日期小于或等于我拥有的最后一条推文的日期.

For checking new tweets I'm thinking about comparing the date of the last tweet I get with the tweet feed (e.g. 5 tweets) until i reach some one with a date less than or equals the last one I have.

所以我的问题简而言之是:

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 ?

推荐答案

有更好的方法.查看文档.

你想使用

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

我最近的推文 ID 为224794768041984001"

My most recent Tweet has 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

这篇关于如何在Android中获取Twitter用户的最新推文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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