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:org.apache.streams.twitter.provider.TwitterFollowingProviderTask.java

License:Apache License

private void collectUsers(Long id) {
    int keepTrying = 0;
    List<twitter4j.User> list = null;
    long curser = -1;

    twitter4j.User user;//from   www. ja va  2s .co m
    String userJson;
    try {
        user = client.users().showUser(id);
        userJson = TwitterObjectFactory.getRawJSON(user);
    } catch (TwitterException ex) {
        LOGGER.error("Failure looking up " + id);
        return;
    }

    do {
        try {

            PagableResponseList<twitter4j.User> page = null;
            if (provider.getConfig().getEndpoint().equals("followers")) {
                page = client.friendsFollowers().getFollowersList(id, curser,
                        provider.getConfig().getPageSize().intValue());
            } else if (provider.getConfig().getEndpoint().equals("friends")) {
                page = client.friendsFollowers().getFriendsList(id, curser,
                        provider.getConfig().getPageSize().intValue());
            }

            Objects.requireNonNull(list);
            Preconditions.checkArgument(list.size() > 0);

            for (twitter4j.User other : list) {

                String otherJson = TwitterObjectFactory.getRawJSON(other);

                try {
                    Follow follow = null;
                    if (provider.getConfig().getEndpoint().equals("followers")) {
                        follow = new Follow().withFollowee(mapper.readValue(userJson, User.class))
                                .withFollower(mapper.readValue(otherJson, User.class));
                    } else if (provider.getConfig().getEndpoint().equals("friends")) {
                        follow = new Follow().withFollowee(mapper.readValue(otherJson, User.class))
                                .withFollower(mapper.readValue(userJson, User.class));
                    }

                    Objects.requireNonNull(follow);

                    if (item_count < provider.getConfig().getMaxItems()) {
                        ComponentUtils.offerUntilSuccess(new StreamsDatum(follow), provider.providerQueue);
                        item_count++;
                    }

                } catch (Exception ex) {
                    LOGGER.warn("Exception: {}", ex);
                }
            }
            if (!page.hasNext()) {
                break;
            }
            if (page.getNextCursor() == 0) {
                break;
            }
            curser = page.getNextCursor();
            page_count++;
        } catch (Exception ex) {
            keepTrying += TwitterErrorHandler.handleTwitterError(client, null, ex);
        }
    } while (provider.shouldContinuePulling(list) && curser != 0
            && keepTrying < provider.getConfig().getRetryMax() && count < provider.getConfig().getMaxItems());
}

From source file:org.apache.streams.twitter.provider.TwitterFriendsProviderTask.java

License:Apache License

protected void getFriends(Long id) {

    int keepTrying = 0;

    long curser = -1;

    do {/*  w  ww  .  j a  v a  2s  . c om*/
        try {
            twitter4j.User follower4j;
            String followerJson;
            try {
                follower4j = client.users().showUser(id);
                followerJson = TwitterObjectFactory.getRawJSON(follower4j);
            } catch (TwitterException e) {
                LOGGER.error("Failure looking up " + id);
                break;
            }

            PagableResponseList<User> followeeList = client.friendsFollowers().getFriendsList(id.longValue(),
                    curser);

            for (twitter4j.User followee4j : followeeList) {

                String followeeJson = TwitterObjectFactory.getRawJSON(followee4j);

                try {
                    Follow follow = new Follow()
                            .withFollowee(
                                    mapper.readValue(followeeJson, org.apache.streams.twitter.pojo.User.class))
                            .withFollower(
                                    mapper.readValue(followerJson, org.apache.streams.twitter.pojo.User.class));

                    ComponentUtils.offerUntilSuccess(new StreamsDatum(follow), provider.providerQueue);
                } catch (JsonParseException e) {
                    LOGGER.warn(e.getMessage());
                } catch (JsonMappingException e) {
                    LOGGER.warn(e.getMessage());
                } catch (IOException e) {
                    LOGGER.warn(e.getMessage());
                }
            }
            curser = followeeList.getNextCursor();
        } catch (TwitterException twitterException) {
            keepTrying += TwitterErrorHandler.handleTwitterError(client, twitterException);
        } catch (Exception e) {
            keepTrying += TwitterErrorHandler.handleTwitterError(client, e);
        }
    } while (curser != 0 && keepTrying < 10);
}

From source file:org.apache.streams.twitter.provider.TwitterFriendsProviderTask.java

License:Apache License

protected void getFriends(String screenName) {

    int keepTrying = 0;

    long curser = -1;

    do {/*from  ww  w .  ja  va  2 s .c  o m*/
        try {
            twitter4j.User follower4j;
            String followerJson;
            try {
                follower4j = client.users().showUser(screenName);
                followerJson = TwitterObjectFactory.getRawJSON(follower4j);
            } catch (TwitterException e) {
                LOGGER.error("Failure looking up " + screenName);
                break;
            }

            PagableResponseList<User> followeeList = client.friendsFollowers().getFriendsList(screenName,
                    curser);

            for (twitter4j.User followee4j : followeeList) {

                String followeeJson = TwitterObjectFactory.getRawJSON(followee4j);

                try {
                    Follow follow = new Follow()
                            .withFollowee(
                                    mapper.readValue(followeeJson, org.apache.streams.twitter.pojo.User.class))
                            .withFollower(
                                    mapper.readValue(followerJson, org.apache.streams.twitter.pojo.User.class));

                    ComponentUtils.offerUntilSuccess(new StreamsDatum(follow), provider.providerQueue);
                } catch (JsonParseException e) {
                    LOGGER.warn(e.getMessage());
                } catch (JsonMappingException e) {
                    LOGGER.warn(e.getMessage());
                } catch (IOException e) {
                    LOGGER.warn(e.getMessage());
                }
            }
            curser = followeeList.getNextCursor();
        } catch (TwitterException twitterException) {
            keepTrying += TwitterErrorHandler.handleTwitterError(client, twitterException);
        } catch (Exception e) {
            keepTrying += TwitterErrorHandler.handleTwitterError(client, e);
        }
    } while (curser != 0 && keepTrying < 10);
}

From source file:org.loklak.scraper.TwitterRiver.java

License:Apache License

/**
 * Get users id of each list to stream them.
 * @param tUserlists List of user list. Should be a public list.
 * @return/* ww w .ja  v a2s  .  c om*/
 */
private long[] getUsersListMembers(String[] tUserlists) {
    logger.debug("Fetching user id of given lists");
    List<Long> listUserIdToFollow = new ArrayList<Long>();
    Configuration cb = buildTwitterConfiguration();
    Twitter twitterImpl = new TwitterFactory(cb).getInstance();

    //For each list given in parameter
    for (String listId : tUserlists) {
        logger.debug("Adding users of list {} ", listId);
        String[] splitListId = listId.split("/");
        try {
            long cursor = -1;
            PagableResponseList<User> itUserListMembers;
            do {
                itUserListMembers = twitterImpl.getUserListMembers(splitListId[0], splitListId[1], cursor);
                for (User member : itUserListMembers) {
                    long userId = member.getId();
                    listUserIdToFollow.add(userId);
                }
            } while ((cursor = itUserListMembers.getNextCursor()) != 0);

        } catch (TwitterException te) {
            logger.error("Failed to get list members for : {}", listId, te);
        }
    }

    //Just casting from Long to long
    long ret[] = new long[listUserIdToFollow.size()];
    int pos = 0;
    for (Long userId : listUserIdToFollow) {
        ret[pos] = userId;
        pos++;
    }
    return ret;
}

From source file:the_vaps_project.The_vaps_project.java

public static void main(String[] args)/* throws TwitterException */ {
    // TODO code application logic here

    /*/*w w  w.ja v a2 s .c o  m*/
            
    List<Status> status = twitter.getHomeTimeline();
    for(Status st : status){
    System.out.println(st.getUser().getName()+"--------"+st.getText());
    System.out.println(st.getCreatedAt());
    }*/

    // The factory instance is re-useable and thread safe.
    /*Twitter twitter2 = tf.getSingleton();
     Query query = new Query("source:twitter4j yusukey");
     QueryResult result = twitter.search(query);
     for (Status statuss : result.getTweets()) {
     System.out.println("@" + statuss.getUser().getName() + ":" + statuss.getText());
     }*/
    TwitterCriteria criteria = null;
    Tweet t = null;
    criteria = TwitterCriteria.create()

            .setMaxTweets(10).setUntil("2016-11-08").setQuerySearch("#NeverTrump");

    /*Scribe s = new Scribe();
    s.detruireFichier("tweets.xml");
    s.ouvrir("tweets.xml");
    s.ecrire("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    s.ecrire("<tweets>\n");
    for (int i = 0; i < TweetManager.getTweets(criteria).size(); i++) {
    t = TweetManager.getTweets(criteria).get(i);
    s.ecrire("\t<tweet>\n");
    s.ecrire("\t\t<text><![CDATA["+t.getText()+"]]></text>\n");
    s.ecrire("\t\t<hashtags>"+t.getHashtags()+"</hashtags>\n");
    s.ecrire("\t\t<date>"+t.getDate()+"</date>\n");
    s.ecrire("\t\t<username>"+t.getUsername()+"</username>\n");
    s.ecrire("\t\t<retweets>"+t.getRetweets()+"</retweets>\n");
    s.ecrire("\t\t<favorites>"+t.getFavorites()+"</favorites>\n");
    s.ecrire("\t\t<id>"+t.getId()+"</id>\n");
    s.ecrire("\t\t<geo>"+t.getGeo()+"</geo>\n");
    s.ecrire("\t\t<mentions>"+t.getMentions()+"</mentions>\n");
    s.ecrire("\t\t<permalink>"+t.getPermalink()+"</permalink>\n");
    s.ecrire("\t\t<smileys>"+t.getSmileys()+"</smileys>\n");
    s.ecrire("\t\t<polarite>"+t.getPolarite()+"</polarite>\n");
    s.ecrire("\t</tweet>\n");
            
    corpus.ecrire(s.filtrerTexte(t.getText() + "\n"));
    }
    s.ecrire("</tweets>");
            
    s.fermer();*/

    /* SUPER SITE D'EXEMPLES
    https://github.com/yusuke/twitter4j/tree/master/twitter4j-examples/src/main/java/twitter4j/examples*/

    /*PARTIE GRAPHE DES RETWEETS*/
    Set<String> nameOfUsers = new HashSet<>();
    for (int i = 0; i < TweetManager.getTweets(criteria).size(); i++) {
        t = TweetManager.getTweets(criteria).get(i);
        System.out.println(t.getUsername());
        nameOfUsers.add(t.getUsername());
    }

    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey("gVaO166IGfSCun5Esj1sZ5bX3")
            .setOAuthConsumerSecret("KhN1L4pXCG5U6d6tee1IGUnIV1bqxieQJDxE2HOx3AGI5npQRE")
            .setOAuthAccessToken("822018210178469888-4Pr1KRE2rmFvof0O5IUdTlxtkGKamU4")
            .setOAuthAccessTokenSecret("D1thDl7k8v2s1SupU5ZGhK3U7Mphb69fpUW4JuDou5O65");
    TwitterFactory tf = new TwitterFactory(cb.build());
    twitter4j.Twitter twitter = tf.getInstance();

    /*String[] screenNames = nameOfUsers.toArray(new String[0]);
    ResponseList<User> usersNames;
    long cursor = -1;
    IDs ids;
    try {
    usersNames = twitter.lookupUsers(screenNames);
    for(User u: usersNames){
        System.out.println(u.getId()+" "+u.getName()+" "+u.getName());
        ids = twitter.getFollowersIDs("username", cursor);
        twitter.getFollowers
    }
                        
            
    } catch (TwitterException ex) {
    Exceptions.printStackTrace(ex);
    }*/

    Set<DuoKey> utilisateurs = new HashSet<>();
    Set<DuoKey> liens = new HashSet<>();

    //User us;

    try {
        int nbpages = 0;
        long cursor = -1;
        PagableResponseList<User> listeFollowersTemp;
        ArrayList<User> listeFollowers = new ArrayList<User>();
        for (String s : nameOfUsers) {
            if (!utilisateurs.contains(new DuoKey(s, "auteurTweet"))) {

                utilisateurs.add(new DuoKey(s, "auteurTweet"));

                //listeFollowersTemp = twitter.getFollowersList(s, -1);
                do {
                    TimeUnit.MINUTES.sleep(1);
                    listeFollowersTemp = twitter.getFollowersList(s, cursor);

                    for (User u : listeFollowersTemp) {
                        listeFollowers.add(u);
                    }
                    nbpages++;
                } while (((cursor = listeFollowersTemp.getNextCursor()) != 0) && nbpages <= 9); //4=100 followers par auteur de tweet recherch
            }
            System.out.println(s + ", mes followers sont :");
            for (User u : listeFollowers) {
                utilisateurs.add(new DuoKey(u.getName(), "auteurTweet"));
                liens.add(new DuoKey(u.getName(), s));
                System.out.println("\t" + u.getName());
            }
            listeFollowers.clear();
            nbpages = 0;
        }
    } catch (TwitterException | InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }

    Scribe sc = new Scribe();
    sc.detruireFichier("graphFollowers.gexf");
    sc.ouvrir("graphFollowers.gexf");
    sc.ecrire("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    sc.ecrire(
            "<gexf xmlns=\"http://www.gexf.net/1.2draft/gexf.xsd\" version=\"1.2\" xmlns:viz=\"http://www.gexf.net/1.1draft/viz\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd\">\n");
    sc.ecrire("\t<meta lastmodifieddate=\"2017-02-17\">\n");
    sc.ecrire("\t\t<creator>Pirboss</creator>\n");
    sc.ecrire("\t\t<description>Test v2</description>\n");
    sc.ecrire("\t</meta>\n");
    sc.ecrire("\t<graph defaultedgetype=\"directed\" mode=\"static\">\n");
    sc.ecrire("\t\t<nodes>\n");
    ArrayList<DuoKey> distinctListOfUsers = new ArrayList(utilisateurs);
    System.out.println(distinctListOfUsers.size());
    for (int i = 0; i < distinctListOfUsers.size(); i++) {
        sc.ecrire("\t\t\t<node id=\"" + distinctListOfUsers.get(i).getX().replace("&", "&amp;") + "\" label=\""
                + distinctListOfUsers.get(i).getX().replace("&", "&amp;") + "\"/>\n");
    }
    sc.ecrire("\t\t</nodes>\n");
    sc.ecrire("\t\t<edges>\n");
    ArrayList<DuoKey> distinctListOfLinks = new ArrayList(liens);
    System.out.println(distinctListOfLinks.size());
    for (int i = 0; i < liens.size(); i++) {
        sc.ecrire("\t\t\t<edge id=\"" + i + "\" source=\""
                + distinctListOfLinks.get(i).getX().replace("&", "&amp;") + "\" target=\""
                + distinctListOfLinks.get(i).getY().replace("&", "&amp;") + "\"/>\n");
    }

    sc.ecrire("\t\t</edges>\n");
    sc.ecrire("\t</graph>\n");
    sc.ecrire("</gexf>");
    sc.fermer();

    PreviewJFrame p = new PreviewJFrame();
    p.script();

    /*PARTIE GRAPHE DES MENTIONS*/
    //NE PAS OUBLIE LE COUP DE REMPLACER LES .replace("&", "&amp;") POUR LE XML 
    /*Set<String> users = new HashSet<>();
    HashMap<DuoKey, Integer> map;
    map = new HashMap<DuoKey, Integer>();
    DuoKey duokey;
    for (int i = 0; i < TweetManager.getTweets(criteria).size(); i++) {
    System.out.println(i);
    t = TweetManager.getTweets(criteria).get(i);
    users.add(t.getUsername());
    if(!t.getMentions().isEmpty()){
        for(String target : t.getMentions().split(" ")){
            target = target.replaceFirst("@", "");
            users.add(target);
            duokey = new DuoKey(t.getUsername(), target);
            if(map.get(duokey) != null){
                map.put(duokey, map.get(duokey)+1);
            }else{
                map.put(duokey, 1);
            }
        }
    }
    }
            
    Scribe s = new Scribe();
    s.detruireFichier("tweets.gexf");
    s.ouvrir("tweets.gexf");
    s.ecrire("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    s.ecrire("<gexf xmlns=\"http://www.gexf.net/1.2draft/gexf.xsd\" version=\"1.2\" xmlns:viz=\"http://www.gexf.net/1.1draft/viz\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd\">\n");
    s.ecrire("\t<meta lastmodifieddate=\"2017-02-17\">\n");
    s.ecrire("\t\t<creator>Pirboss</creator>\n");
    s.ecrire("\t\t<description>Test v1</description>\n");
    s.ecrire("\t</meta>\n");
    s.ecrire("\t<graph defaultedgetype=\"directed\" mode=\"static\">\n");
    s.ecrire("\t\t<nodes>\n");
    ArrayList distinctList = new ArrayList(users);
    for(int i=0; i<distinctList.size(); i++){
    s.ecrire("\t\t\t<node id=\""+i+"\" label=\""+distinctList.get(i)+"\"/>\n");
    }
    s.ecrire("\t\t</nodes>\n");
    s.ecrire("\t\t<edges>\n");
    Iterator ite = map.entrySet().iterator();
    int jj=0;
    while (ite.hasNext()) {
    Map.Entry pair = (Map.Entry)ite.next();
    s.ecrire("\t\t\t<edge id=\""+(jj++)+"\" source=\""+distinctList.indexOf(((DuoKey)pair.getKey()).getX())+"\" target=\""+distinctList.indexOf(((DuoKey)pair.getKey()).getY())+"\" weight=\""+pair.getValue()+"\"/>\n");
    ite.remove(); // avoids a ConcurrentModificationException
    }
    s.ecrire("\t\t</edges>\n");
    s.ecrire("\t</graph>\n");
    s.ecrire("</gexf>");
    s.fermer();
            
    PreviewJFrame pr = new PreviewJFrame();
    pr.script();*/
}

From source file:tientx.supercode.myproejectdemov3.preprocessing.GetTwitterAccount.java

public static PagableResponseList<User> get2000Account(TwitterService ts, String originUserScreenName) {
    try {/*from   ww w . j a v  a 2s.  c o m*/
        PagableResponseList<User> listFollower = ts.getTwUserFollowerList(originUserScreenName, (long) -1, 200);
        System.out.println("Turn " + 1 + " : " + listFollower.size());
        Thread.sleep(15000);

        long cursor = listFollower.getNextCursor();
        for (int i = 2; i <= 10; i++) {
            PagableResponseList<User> list = ts.getTwUserFollowerList(originUserScreenName, cursor, 200);
            System.out.println("Turn " + i + " : " + list.size());
            if (list != null && list.size() > 0) {
                listFollower.addAll(list);
            }
            cursor = list.getNextCursor();
            if (i != 10) {
                Thread.sleep(15000);
            }
        }

        System.out.println("All : " + listFollower.size());
        listFollower.stream().forEach((list) -> {
            System.out.println("ID follower : " + list.getId());
            System.out.println("Follower screen name : " + list.getScreenName());
            System.out.println("-------------------------");
        });
        return listFollower;
    } catch (TwitterException | InterruptedException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:tientx.supercode.myproejectdemov3.preprocessing.GetTwitterAccount.java

public static PagableResponseList<User> getAllFriend(TwitterService ts, Long idUser) {
    try {/*  w  w  w.j  ava2 s.com*/
        int i = 1;
        PagableResponseList<User> listFriend = ts.getTwUserFriendListId(idUser, (long) -1, 200);
        System.out.println("Turn " + i + " : " + listFriend.size());
        Thread.sleep(15000);

        long cursor = listFriend.getNextCursor();
        PagableResponseList<User> list;
        do {
            list = ts.getTwUserFollowerList(idUser, cursor, 200);
            System.out.println("Turn " + ++i + " : " + list.size());
            if (list != null && list.size() > 0) {
                listFriend.addAll(list);
            }
            cursor = list.getNextCursor();
            Thread.sleep(15000);
        } while (list != null && list.size() > 0);
        System.out.println("All : " + listFriend.size());
        return listFriend;
    } catch (TwitterException | InterruptedException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:twitter.crawler.TwitterCrawler.java

public static void main(String[] args) {
    try {//from  w  w w. ja  v  a 2 s  .  c  o  m
        // Authorise the library
        ConfigurationBuilder cb = new ConfigurationBuilder();
        cb.setOAuthConsumerKey("AhoydO8uSe4v8NEq7j2ISGFlq");
        cb.setOAuthConsumerSecret("ptKEYwq3G9vpFkqAhvwFLSWFcBW8U1SfqycECwK4cH6wThVba6");
        cb.setOAuthAccessToken("778240255577194496-taafqDIHebrg972oxT5kTqcNd3Uojod");
        cb.setOAuthAccessTokenSecret("DMRmeRahnLJRvCBIGQGTaTzE6Pr3PAZMgMsfWIT5ue3PD");
        Twitter twitter = new TwitterFactory(cb.build()).getInstance();
        User user = twitter.verifyCredentials(); // Get main user

        long cursor = -1;

        // Print user profile
        System.out.println("@" + user.getScreenName());
        System.out.println(user.getId());
        System.out.println(user.getProfileImageURL());
        System.out.println(user.getFriendsCount() + " friends.");
        System.out.println("-------");

        // Print Home Timeline
        List<Status> statuses = twitter.getHomeTimeline();
        System.out.println("Showing @" + user.getScreenName() + "'s home timeline.");

        for (Status status : statuses) {
            System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
        }

        //Print followers
        System.out.println("-------");
        System.out.println("Showing Follwers:");

        PagableResponseList<User> followers;

        //do
        //{
        followers = twitter.getFollowersList(user.getScreenName(), cursor);

        for (User follower : followers) {
            System.out.println("@" + follower.getScreenName());
        }
        //}
        //while ((cursor = followers.getNextCursor())!=-1);

        //Print follwees

        System.out.println("-------");
        System.out.println("Showing Followees:");

        PagableResponseList<User> followees;

        do {
            followees = twitter.getFriendsList(user.getScreenName(), cursor);

            for (User followee : followees) {
                System.out.println("@" + followee.getScreenName());
            }
        } while ((cursor = followees.getNextCursor()) != -1);
    }

    catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get timeline: " + te.getMessage());
        System.exit(-1);
    }
}

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

License:Apache License

/**
 * Usage: java twitter4j.examples.list.GetUserListMembers [list owner screen name] [list id]
 *
 * @param args message//from   ww w  . j  a  va 2  s.  c  om
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.list.GetUserListMembers [list id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long cursor = -1;
        PagableResponseList<User> usres;
        do {
            usres = twitter.getUserListMembers(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 members: " + te.getMessage());
        System.exit(-1);
    }
}

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

License:Apache License

/**
 * Usage: java twitter4j.examples.list.GetUserListMemberships [list member screen name]
 *
 * @param args message//from   w ww . j  a va 2  s .c  om
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println(
                "Usage: java twitter4j.examples.list.GetUserListMemberships [list member screen name]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long cursor = -1;
        PagableResponseList<UserList> lists;
        do {
            lists = twitter.getUserListMemberships(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);
    }
}