开发者

More than 100 search results with Jtwitter

开发者 https://www.devze.com 2023-04-03 07:16 出处:网络
I have a fu开发者_如何学Cnction that does the following: List<Status> list = new ArrayList<Status>();

I have a fu开发者_如何学Cnction that does the following:

List<Status> list = new ArrayList<Status>();
Twitter twitter = new Twitter();
int num = 300;        
ICallback call = new ICallback() {

    public boolean process(List<Status> statuses) {
        return false;
    }
};
list = twitter.search(hashTag, call, num);  

I'm trying to retrieve 300 results, but instead I get 100. The return value of the ICallback makes no difference.

What could be the problem?


I looked at the source and it looks like the there is a maxResults field that defaults to 100 that restricts the number of results. Just try setting it to 300 or more for your scenario.

Try

twitter.setMaxResults(500);
list = twitter.search(hashTag, call, num);  


The twitter search API documentation says

rpp optional - paramter 

The number of tweets to return per page, up to a max of 100.

per page max results is 100.

page optional - parameter 

The page number (starting at 1) to return, up to a max of roughly 1500 results (based on rpp * page).

Have a look at documentation for more details


check this:

https://dev.twitter.com/docs/api/1/get/search

rpp: The number of tweets to return per page, up to a max of 100. Example Values: 100

In jTwitter api, search method the third parameter is the rpp! So up to 100!

To solve that set the MaxResults! however I also remember that I was using jtwitter for search like that but the API had some bugs about pagination in more the 100 tweets! anyways it is worth you give a try setting the maxResults! otherwise try using twitter4j which I think it is a better api for Java and Twitter

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号