Getting tweets with specific hashtag from a user's timeline using Fabric in android

此生再无相见时 提交于 2019-12-04 19:29:13

It's a little rough, but here's how to get the user tweets

ArrayList<Tweet> tweets = new ArrayList<>();
TwitterCore.getInstance().getApiClient(session).getStatusesService()
    .userTimeline(null,
            "screenname",
            10 //the number of tweets we want to fetch,
            null,
            null,
            null,
            null,
            null,
            null,
            new Callback<List<Tweet>>() {
                @Override
                public void success(Result<List<Tweet>> result) {
                    for (Tweet t : result.data) {
                        tweets.add(t);
                        android.util.Log.d("twittercommunity", "tweet is " + t.text);
                    }
                }

                @Override
                public void failure(TwitterException exception) {
                    android.util.Log.d("twittercommunity", "exception " + exception);
                }
            });

Then what I would do, is a quick conditional to determine if the Tweet object contains the hashtags that you want from the entities attribute. I'll need to play with this a bit to give you the exact answer you need. I looked at the API, unfortunately there is no argument that I can find for getting a user's timeline and subsequently filtering by tag. So I think you'll need to iterate through. Here's a good reference to the userTimeline() method of the StatusesService class https://twittercommunity.com/t/android-usertimeline-question/30263/2

Again, I will update this answer when I have a chance later today

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!