简体   繁体   中英

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

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.

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.

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"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM