Example usage for twitter4j PagableResponseList getNextCursor

List of usage examples for twitter4j PagableResponseList getNextCursor

Introduction

In this page you can find the example usage for twitter4j PagableResponseList getNextCursor.

Prototype

@Override
    long getNextCursor();

Source Link

Usage

From source file:twitter4j.examples.list.GetUserListSubscribers.java

License:Apache License

/**
 * Usage: java twitter4j.examples.list.GetUserListSubscribers [list id]
 *
 * @param args message//from www . jav  a 2 s .c  om
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.list.GetUserListSubscribers [list id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long cursor = -1;
        PagableResponseList<User> usres;
        do {
            usres = twitter.getUserListSubscribers(Integer.parseInt(args[0]), cursor);
            for (User list : usres) {
                System.out.println("@" + list.getScreenName());
            }
        } while ((cursor = usres.getNextCursor()) != 0);
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get list subscribers: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.list.GetUserListSubscriptions.java

License:Apache License

/**
 * Usage: java twitter4j.examples.list.GetUserListSubscriptions [screen name]
 *
 * @param args message/*from   ww  w  .  ja  v a 2 s.co m*/
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.list.GetUserListSubscriptions [screen name]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long cursor = -1;
        PagableResponseList<UserList> lists;
        do {
            lists = twitter.getUserListSubscriptions(args[0], cursor);
            for (UserList list : lists) {
                System.out.println("id:" + list.getId() + ", name:" + list.getName() + ", description:"
                        + list.getDescription() + ", slug:" + list.getSlug() + "");
            }
        } while ((cursor = lists.getNextCursor()) != 0);
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to list the lists: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:uk.co.flax.ukmp.twitter.PartyListHandler.java

License:Apache License

private Set<Long> readPartyIds(Twitter twitter, String screenName, String slug, String party) {
    Set<Long> ids = new HashSet<>();

    try {//  www . j  a  v  a 2 s . c o  m
        long cursor = -1;
        PagableResponseList<User> response = null;
        do {
            response = twitter.getUserListMembers(screenName, slug, cursor);
            for (User user : response) {
                LOGGER.debug("Read id for user @{}", user.getScreenName());
                ids.add(user.getId());
            }
            cursor = response.getNextCursor();
        } while (response != null && response.hasNext());
    } catch (TwitterException e) {
        LOGGER.error("Twitter exception updating {} party list : {}", party, e.getMessage());
    }

    return ids;
}