简体   繁体   English

如何在Android中获取Twitter用户的最新推文

[英]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.

相关问题 在 Android 应用程序中显示来自用户推特帐户的推文 - Displaying tweets from user's twitter accounts in an android app Android如何在使用Twitter进行身份验证后获取用户的全名 - Android how to get user's full name after authentication with Twitter 如何通过twitter的Fabric API(Android)获取用户数据 - How to get user data through twitter's Fabric API (Android) 如何在Android Studio中使用Fabric获取特定用户的时间轴并查看其推文? - How to get a specific user's timeline and view their tweets by using fabric in android studio? Android版Fabric和twitter4j都找不到包含特定用户提及的推文 - Neither Fabric for Android nor twitter4j find tweets containing a specific user's mention 如何从Android中的特定用户的Twitter获取推文?(想要显示推文(由登录用户完成)在我的列表视图中) - How to get Tweets from Twitter of perticular User in Android ?(Want to show tweets(Done by signin User) in my list view) 从用户的时间轴获取推文 - Get tweets from user's timeline 使用Fabric的Android Twitter SDK获得特定用户的公共推文 - Android twitter sdk using fabric Get public tweets of particular user 如何在Android中从用户的Twitter用户名中找到用户的Twitter ID - How do you find a user's twitter id from a user's twitter username in Android 从 Twitter (Android) 获取用户的电子邮件地址 - Get a User's email address from Twitter (Android)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM