Android, getting new tweets from specific users

android

#1

Hi all. I have a feature id like to implement where i display the latest tweets from specific twitter users. Can someone give me some info on how this would best be done? Would the rest apis or streaming apis be used in this case? Or could it be implemented with either one?

EDIT: Also, what is the use case for Fabric on Android? What exactly is Fabric?


#2

Could do it with either - but https://dev.twitter.com/rest/reference/get/statuses/user_timeline REST API would be adequate. Twitter4J works well with Android - twitter4j-core-4.0.x.jar is all you’ll need.

Example here https://github.com/yusuke/twitter4j/blob/master/twitter4j-examples/src/main/java/twitter4j/examples/timeline/GetUserTimeline.java & javadoc: http://twitter4j.org/javadoc/twitter4j/api/TimelinesResources.html#getUserTimeline--


#3

Thanks! Ill take a look. Now is there any significant features that I would be missing out on using the REST api over the Streaming API? I’m assuming the Streaming API would keep a connection open and notify in real time of new tweets, but because I dont need up to the second updates of tweets im guessing the REST api will work great.


#4

Yep - have a look at https://dev.twitter.com/rest/public/timelines to make those REST API calls more efficient and only request new tweets. (In Twitter4J since_id, max_id, count parameters can be set with a Paging object http://twitter4j.org/javadoc/twitter4j/Paging.html)


#5

Thanks for the help. I wanted to ask, is Fabric now the way to go? I know Twitter4J has been to go-to for a long time, but I’ve started hearing more about Fabric now that its been out awhile. Do you recommend using Fabric over Twitter4J? Actually, can this even be done with Fabric?


#6

Yeah - now that you mention it, Fabric is another way you can do this. Don’t have much experience with it - but the UserTimeline thing looks like it’s straight forward to implement https://docs.fabric.io/android/twitter/show-timelines.html may be easier for Android.


#7

Ended up making a test project to test out Fabric. The docs arent good at all, but finally managed to get a small timeline working with guest authentication. The solution I tried with Twitter4J was a bit more straightfoward, so will probably move foward with that.


Test run with Fabric (Android)
#8

@orb_yt, sorry to hear the Fabric docs didn’t help much. Would mind providing your feedback in the Fabric forum. The team is very attentive to these type of issues and docs are something we can improve fairly easily.


#9

Done: Test run with Fabric (Android)

Let me know if you have any input on my review, or solutions to the problems I had!