Example usage for twitter4j Twitter createUserListMembers

List of usage examples for twitter4j Twitter createUserListMembers

Introduction

In this page you can find the example usage for twitter4j Twitter createUserListMembers.

Prototype

UserList createUserListMembers(long listId, long... userIds) throws TwitterException;

Source Link

Document

Adds multiple members to a list, by specifying a comma-separated list of member ids or screen names.

Usage

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

License:Apache License

/**
 * Usage: java twitter4j.examples.list.CreateUserListMembers [list id] [screen name[,screen name..]]
 *
 * @param args message//  w w w . ja  v  a 2  s.c o  m
 */
public static void main(String[] args) {
    if (args.length < 2) {
        System.out.println(
                "Usage: java twitter4j.examples.list.CreateUserListMembers [list id] [screen name[,screen name..]]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.createUserListMembers(Integer.parseInt(args[0]), args[1].split(","));
        System.out.println("Successfully added the user(s) to the specified list.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to add a user: " + te.getMessage());
        System.exit(-1);
    }
}