Twitter4j. Making query and filtering posts by #hashtag

百般思念 提交于 2019-12-07 05:32:12

问题


I am trying to integrate twitter (using Twitter4j) into my android app and I have few concerns/questions:

I want to retrieve tweets that have certain #hashtag, for example #sxbsw2011. Here is the code that I am currently using:

Query query = new Query("#sxsw2011 since:2010-11-21");  
QueryResult result = twitter.search(query);  
for (Tweet tweet : result.getTweets())  
{  
     Log.d(TAG, tweet.getId() + " " + tweet.getFromUser() + " : " + tweet.getText());  
}

I want to put result into one of my views on my layout witch serves as conversation screen. My problem is I want to run this query every few, 4 or 5, seconds in order to get new comments. But with every search I would get all tweets that are created today. Then I would have to use tweet ID's to exclude those that are already shown on my conversation window. To me this seems wrong. Is there any other way to search for tweets and to specify some time span like few minutes? Is there better way of doing what I want? I tried to use StatusListener, but have problem trying to figure how to use getFilterStream().

What are twitter limitations. How many times my app (it will be running on multiple user devices) can request result?

The icon 101010 in editor is not working so it's sort of impossible to make correct code indentation when typing the post.

来源:https://stackoverflow.com/questions/4241861/twitter4j-making-query-and-filtering-posts-by-hashtag

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