Example usage for twitter4j Paging Paging

List of usage examples for twitter4j Paging Paging

Introduction

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

Prototype

public Paging(long sinceId) 

Source Link

Usage

From source file:com.illusionaryone.TwitterAPI.java

License:Open Source License

public List<Status> getMentions(long sinceId) {
    if (accessToken == null) {
        com.gmt2001.Console.debug.println("Access Token is NULL");
        return null;
    }//  w w  w  . j  a v  a  2  s . c o  m

    try {
        com.gmt2001.Console.debug.println("Polling Data");
        if (sinceId != 0L) {
            Paging paging = new Paging(sinceId);
            List<Status> statuses = twitter.getMentionsTimeline(paging);
            if (statuses.isEmpty()) {
                return null;
            }
            return statuses;
        } else {
            List<Status> statuses = twitter.getMentionsTimeline();
            if (statuses.isEmpty()) {
                return null;
            }
            return statuses;
        }
    } catch (TwitterException ex) {
        com.gmt2001.Console.err.println("Failed: " + ex.getMessage());
        return null;
    }
}

From source file:com.javielinux.api.loaders.LoadTypeStatusLoader.java

License:Apache License

@Override
public BaseResponse loadInBackground() {

    try {//from   w ww .j a  v  a 2 s . c  o m
        LoadTypeStatusResponse response = new LoadTypeStatusResponse();
        ArrayList<InfoTweet> result = new ArrayList<InfoTweet>();

        ConnectionManager.getInstance().open(getContext());

        if (request.getType() == FAVORITES) {
            ResponseList<Status> statii = ConnectionManager.getInstance().getTwitter(request.getUserId())
                    .getFavorites();

            for (int i = 0; i < statii.size(); i++) {
                result.add(new InfoTweet(statii.get(i)));
            }
        } else if (request.getType() == SEARCH_USERS) {
            ResponseList<User> users = ConnectionManager.getInstance().getTwitter(request.getUserId())
                    .searchUsers(request.getUserSearchText(), 0);

            for (User user : users) {
                InfoTweet row = new InfoTweet(user);
                result.add(row);
            }
        } else if (request.getType() == RETWEETED_BYME) {
            // TODO retweet
            //            ResponseList<Status> statii = ConnectionManager.getInstance().getTwitter(request.getUserId()).getRetweetedByMe();
            //
            //            for (int i=0; i<statii.size(); i++) {
            //               result.add(new InfoTweet(statii.get(i)));
            //            }
        } else if (request.getType() == RETWEETED_TOME) {
            // TODO retweet
            //            ResponseList<Status> statii = ConnectionManager.getInstance().getTwitter(request.getUserId()).getRetweetedToMe();
            //
            //            for (int i=0; i<statii.size(); i++) {
            //               result.add(new InfoTweet(statii.get(i)));
            //            }
        } else if (request.getType() == RETWEETED_OFME) {
            ResponseList<Status> statii = ConnectionManager.getInstance().getTwitter(request.getUserId())
                    .getRetweetsOfMe();

            for (int i = 0; i < statii.size(); i++) {
                result.add(new InfoTweet(statii.get(i)));
            }
        } else if (request.getType() == FOLLOWERS) {
            ResponseList<User> users = ConnectionManager.getInstance().getUserForSearchesTwitter()
                    .lookupUsers(request.getUserIdList());

            for (User user : users) {
                InfoTweet row = new InfoTweet(user);
                result.add(row);
            }
        } else if (request.getType() == FRIENDS) {
            ResponseList<User> users = ConnectionManager.getInstance().getUserForSearchesTwitter()
                    .lookupUsers(request.getUserIdList());

            for (User user : users) {
                InfoTweet row = new InfoTweet(user);
                result.add(row);
            }
        } else if (request.getType() == TIMELINE) {
            ResponseList<twitter4j.Status> statii = ConnectionManager.getInstance()
                    .getTwitter(request.getUserId()).getHomeTimeline();
            for (int i = 0; i < statii.size(); i++) {
                result.add(new InfoTweet(statii.get(i)));
            }
        } else if (request.getType() == LIST) {
            ResponseList<twitter4j.Status> statii;

            if (request.getUserId() < 0) {
                statii = ConnectionManager.getInstance().getUserForSearchesTwitter()
                        .getUserListStatuses(request.getListId(), new Paging(1));
            } else {
                statii = ConnectionManager.getInstance().getTwitter(request.getUserId())
                        .getUserListStatuses(request.getListId(), new Paging(1));
            }

            for (int i = 0; i < statii.size(); i++) {
                result.add(new InfoTweet(statii.get(i)));
            }
        } else if (request.getType() == USER_TIMELINE) {
            ResponseList<twitter4j.Status> statii = ConnectionManager.getInstance().getUserForSearchesTwitter()
                    .getUserTimeline(request.getUser());
            for (int i = 0; i < statii.size(); i++) {
                result.add(new InfoTweet(statii.get(i)));
            }
        }

        response.setInfoTweets(result);
        return response;

    } catch (TwitterException e) {
        e.printStackTrace();
        ErrorResponse response = new ErrorResponse();
        response.setError(e, e.getMessage());
        return response;
    } catch (OutOfMemoryError e) {
        e.printStackTrace();
        ErrorResponse response = new ErrorResponse();
        response.setError(e, e.getMessage());
        return response;
    } catch (Exception e) {
        e.printStackTrace();
        ErrorResponse response = new ErrorResponse();
        response.setError(e, e.getMessage());
        return response;
    }
}

From source file:com.javielinux.widget.ServiceWidgetTweets4x2.java

License:Apache License

public void update(Context context) {

    blocked = true;/* w  ww.j av  a 2  s  . c  om*/

    mCurrentTweet = 0;

    RemoteViews mRemoteLoading = new RemoteViews(context.getPackageName(), R.layout.widget_loading);
    getManager().updateAppWidget(getWidget(), mRemoteLoading);

    mTweets.clear();
    clearImagesTweets();

    mType = PreferenceUtils.getTypeWidget(context);
    mCurrentSearch = PreferenceUtils.getIdSearchWidget(context);
    long column_id = PreferenceUtils.getWidgetColumn(context);

    try {
        column = new Entity("columns", column_id);
    } catch (CursorIndexOutOfBoundsException e) {
    } catch (Exception e) {
    }

    if (column != null) {

        ArrayList<Entity> tweetList = new ArrayList<Entity>();

        switch (column.getInt("type_id")) {
        case TweetTopicsUtils.COLUMN_TIMELINE:
            //loadUser(columns.get(0).getEntity("user_id").getId());
            tweetList
                    .addAll(DataFramework.getInstance().getEntityList(
                            "tweets_user", "type_id=" + TweetTopicsUtils.TWEET_TYPE_TIMELINE
                                    + " and user_tt_id=" + column.getEntity("user_id").getId(),
                            "date desc", "0,10"));

            for (int i = 0; i < tweetList.size(); i++) {
                mTweets.add(new InfoTweet(tweetList.get(i)));
            }
            break;
        case TweetTopicsUtils.COLUMN_MENTIONS:
            //loadUser(columns.get(0).getEntity("user_id").getId());
            tweetList
                    .addAll(DataFramework.getInstance().getEntityList(
                            "tweets_user", "type_id=" + TweetTopicsUtils.TWEET_TYPE_MENTIONS
                                    + " and user_tt_id=" + column.getEntity("user_id").getId(),
                            "date desc", "0,10"));

            for (int i = 0; i < tweetList.size(); i++) {
                mTweets.add(new InfoTweet(tweetList.get(i)));
            }
            break;
        case TweetTopicsUtils.COLUMN_DIRECT_MESSAGES:
            //loadUser(columns.get(0).getEntity("user_id").getId());
            tweetList
                    .addAll(DataFramework.getInstance().getEntityList(
                            "tweets_user", "type_id=" + TweetTopicsUtils.TWEET_TYPE_DIRECTMESSAGES
                                    + " and user_tt_id=" + column.getEntity("user_id").getId(),
                            "date desc", "0,10"));

            for (int i = 0; i < tweetList.size(); i++) {
                mTweets.add(new InfoTweet(tweetList.get(i)));
            }
            break;
        case TweetTopicsUtils.COLUMN_SEARCH:
            try {
                EntitySearch entitySearch = new EntitySearch(column.getLong("search_id"));
                QueryResult result = twitter.search(entitySearch.getQuery(context));
                ArrayList<Status> tweets = (ArrayList<Status>) result.getTweets();

                for (int i = 0; i < 10; i++) {
                    mTweets.add(new InfoTweet(tweets.get(i)));
                }
            } catch (TwitterException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
            break;
        //                case TweetTopicsUtils.COLUMN_RETWEETS_BY_OTHERS:
        //                    // TODO retweet
        //                    try {
        //                        ResponseList<Status> statii = ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).getRetweetsOfMe();
        //
        //                        for (int i=0; i<statii.size(); i++) {
        //                            mTweets.add(new InfoTweet(statii.get(i)));
        //                        }
        //                    } catch (TwitterException e) {
        //                        e.printStackTrace();
        //                    } catch (Exception e) {
        //                        e.printStackTrace();
        //                    }
        //                    break;
        //                case TweetTopicsUtils.COLUMN_RETWEETS_BY_YOU:
        //                    // TODO retweet
        ////                    try {
        ////                        ResponseList<Status> statii = ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).getRetweetedByMe();
        ////
        ////                        for (int i=0; i<statii.size(); i++) {
        ////                            mTweets.add(new InfoTweet(statii.get(i)));
        ////                        }
        ////                    } catch (TwitterException e) {
        ////                        e.printStackTrace();
        ////                    } catch (Exception e) {
        ////                        e.printStackTrace();
        ////                    }
        //                    break;
        //                case TweetTopicsUtils.COLUMN_FAVORITES:
        //                    try {
        //                        ResponseList<Status> statii = ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).getFavorites();
        //
        //                        for (int i=0; i<statii.size(); i++) {
        //                            mTweets.add(new InfoTweet(statii.get(i)));
        //                        }
        //                    } catch (TwitterException e) {
        //                        e.printStackTrace();
        //                    } catch (Exception e) {
        //                        e.printStackTrace();
        //                    }
        //                    break;
        //                case TweetTopicsUtils.COLUMN_FOLLOWERS:
        //                    try {
        //                        IDs followers_ids = ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).getFollowersIDs(column.getEntity("user_id").getString("name"), -1);
        //
        //                        ResponseList<User> users = null;
        //
        //                        if (followers_ids.getIDs().length <= 100) {
        //                            users = ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).lookupUsers(followers_ids.getIDs());
        //                        } else {
        //                            int hundred_count = followers_ids.getIDs().length / 100;
        //
        //                            for (int i=0; i < hundred_count; i++) {
        //                                if (users == null)
        //                                    users = ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).lookupUsers(Arrays.copyOfRange(followers_ids.getIDs(), i * 100, (i + 1) * 100 - 1));
        //                                else
        //                                    users.addAll(ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).lookupUsers(Arrays.copyOfRange(followers_ids.getIDs(),i*100,(i+1)*100-1)));
        //                            }
        //
        //                            if (followers_ids.getIDs().length % 100 > 0)
        //                                users.addAll(ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).lookupUsers(Arrays.copyOfRange(followers_ids.getIDs(),hundred_count*100 + 1,followers_ids.getIDs().length-1)));
        //                        }
        //
        //                        for (User user : users) {
        //                            InfoTweet row = new InfoTweet(user);
        //                            mTweets.add(row);
        //                        }
        //                    } catch (TwitterException e) {
        //                        e.printStackTrace();
        //                    } catch (Exception e) {
        //                        e.printStackTrace();
        //                    }
        //                    break;
        //                case TweetTopicsUtils.COLUMN_FOLLOWINGS:
        //                    try {
        //                        IDs friends_ids = ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).getFriendsIDs(column.getEntity("user_id").getString("name"), -1);
        //
        //                        ResponseList<User> users = null;
        //
        //                        if (friends_ids.getIDs().length <= 100) {
        //                            users = ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).lookupUsers(friends_ids.getIDs());
        //                        } else {
        //                            int hundred_count = friends_ids.getIDs().length / 100;
        //
        //                            for (int i=0; i < hundred_count; i++) {
        //                                if (users == null)
        //                                    users = ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).lookupUsers(Arrays.copyOfRange(friends_ids.getIDs(), i * 100, (i + 1) * 100 - 1));
        //                                else
        //                                    users.addAll(ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).lookupUsers(Arrays.copyOfRange(friends_ids.getIDs(),i*100,(i+1)*100-1)));
        //                            }
        //
        //                            if (friends_ids.getIDs().length % 100 > 0)
        //                                users.addAll(ConnectionManager.getInstance().getTwitter(column.getEntity("user_id").getId()).lookupUsers(Arrays.copyOfRange(friends_ids.getIDs(),hundred_count*100 + 1,friends_ids.getIDs().length-1)));
        //                        }
        //
        //                        for (User user : users) {
        //                            InfoTweet row = new InfoTweet(user);
        //                            mTweets.add(row);
        //                        }
        //                    } catch (TwitterException e) {
        //                        e.printStackTrace();
        //                    } catch (Exception e) {
        //                        e.printStackTrace();
        //                    }
        //                    break;
        case TweetTopicsUtils.COLUMN_LIST_USER:
            try {
                Entity user_list_entity = new Entity("user_lists",
                        Long.parseLong(column.getValue("userlist_id").toString()));

                ResponseList<twitter4j.Status> statii = ConnectionManager.getInstance()
                        .getTwitter(user_list_entity.getLong("user_id"))
                        .getUserListStatuses(user_list_entity.getInt("userlist_id"), new Paging(1));
                for (int i = 0; i < 10; i++) {
                    mTweets.add(new InfoTweet(statii.get(i)));
                }
            } catch (TwitterException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    blocked = false;

}

From source file:com.klinker.android.twitter.services.DirectMessageRefreshService.java

License:Apache License

@Override
public void onHandleIntent(Intent intent) {
    sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);

    Context context = getApplicationContext();
    AppSettings settings = AppSettings.getInstance(context);

    // if they have mobile data on and don't want to sync over mobile data
    if (Utils.getConnectionStatus(context) && !settings.syncMobile) {
        return;//from w w  w  .j  a va2s.  c om
    }

    boolean update = false;
    int numberNew = 0;

    try {
        Twitter twitter = Utils.getTwitter(context, settings);

        int currentAccount = sharedPrefs.getInt("current_account", 1);

        User user = twitter.verifyCredentials();
        long lastId = sharedPrefs.getLong("last_direct_message_id_" + currentAccount, 0);
        Paging paging;
        if (lastId != 0) {
            paging = new Paging(1).sinceId(lastId);
        } else {
            paging = new Paging(1, 500);
        }

        List<DirectMessage> dm = twitter.getDirectMessages(paging);
        List<DirectMessage> sent = twitter.getSentDirectMessages(paging);

        if (dm.size() != 0) {
            sharedPrefs.edit().putLong("last_direct_message_id_" + currentAccount, dm.get(0).getId()).commit();
            numberNew = dm.size();
        } else {
            numberNew = 0;
        }

        DMDataSource dataSource = DMDataSource.getInstance(context);
        int inserted = 0;

        for (DirectMessage directMessage : dm) {
            try {
                dataSource.createDirectMessage(directMessage, currentAccount);
            } catch (Exception e) {
                dataSource = DMDataSource.getInstance(context);
                dataSource.createDirectMessage(directMessage, currentAccount);
            }
            inserted++;
        }

        for (DirectMessage directMessage : sent) {
            try {
                dataSource.createDirectMessage(directMessage, currentAccount);
            } catch (Exception e) {
                dataSource = DMDataSource.getInstance(context);
                dataSource.createDirectMessage(directMessage, currentAccount);
            }
        }

        sharedPrefs.edit().putBoolean("refresh_me", true).commit();
        sharedPrefs.edit().putBoolean("refresh_me_dm", true).commit();

        if (settings.notifications && settings.dmsNot && inserted > 0) {
            int currentUnread = sharedPrefs.getInt("dm_unread_" + currentAccount, 0);
            sharedPrefs.edit().putInt("dm_unread_" + currentAccount, numberNew + currentUnread).commit();

            NotificationUtils.refreshNotification(context);
        }

        if (settings.syncSecondMentions) {
            startService(new Intent(context, SecondDMRefreshService.class));
        }

    } catch (TwitterException e) {
        // Error in updating status
        Log.d("Twitter Update Error", e.getMessage());
    }
}

From source file:com.klinker.android.twitter.services.SecondDMRefreshService.java

License:Apache License

@Override
public void onHandleIntent(Intent intent) {
    sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);

    Context context = getApplicationContext();
    AppSettings settings = AppSettings.getInstance(context);

    // if they have mobile data on and don't want to sync over mobile data
    if (Utils.getConnectionStatus(context) && !settings.syncMobile) {
        return;/*w  ww. jav a2s .  c  o m*/
    }

    boolean update = false;
    int numberNew = 0;

    try {
        Twitter twitter = Utils.getSecondTwitter(context);

        int currentAccount = sharedPrefs.getInt("current_account", 1);

        if (currentAccount == 1) {
            currentAccount = 2;
        } else {
            currentAccount = 1;
        }

        User user = twitter.verifyCredentials();
        long lastId = sharedPrefs.getLong("last_direct_message_id_" + currentAccount, 0);
        Paging paging;
        if (lastId != 0) {
            paging = new Paging(1).sinceId(lastId);
        } else {
            paging = new Paging(1, 500);
        }

        List<DirectMessage> dm = twitter.getDirectMessages(paging);
        List<DirectMessage> sent = twitter.getSentDirectMessages(paging);

        if (dm.size() != 0) {
            sharedPrefs.edit().putLong("last_direct_message_id_" + currentAccount, dm.get(0).getId()).commit();
            numberNew = dm.size();
        } else {
            numberNew = 0;
        }

        DMDataSource dataSource = DMDataSource.getInstance(context);
        int inserted = 0;

        for (DirectMessage directMessage : dm) {
            try {
                dataSource.createDirectMessage(directMessage, currentAccount);
            } catch (Exception e) {
                dataSource = DMDataSource.getInstance(context);
                dataSource.createDirectMessage(directMessage, currentAccount);
            }
            inserted++;
        }

        for (DirectMessage directMessage : sent) {
            try {
                dataSource.createDirectMessage(directMessage, currentAccount);
            } catch (Exception e) {
                dataSource = DMDataSource.getInstance(context);
                dataSource.createDirectMessage(directMessage, currentAccount);
            }
        }

        sharedPrefs.edit().putBoolean("refresh_me", true).commit();
        sharedPrefs.edit().putBoolean("refresh_me_dm", true).commit();

        if (settings.notifications && settings.dmsNot && inserted > 0) {
            int currentUnread = sharedPrefs.getInt("dm_unread_" + currentAccount, 0);
            sharedPrefs.edit().putInt("dm_unread_" + currentAccount, numberNew + currentUnread).commit();

            NotificationUtils.notifySecondDMs(context, currentAccount);
        }

    } catch (TwitterException e) {
        // Error in updating status
        Log.d("Twitter Update Error", e.getMessage());
    }
}

From source file:com.michaelfitzmaurice.clocktwerk.TweetResponder.java

License:Apache License

public Collection<Status> getNewMentions() throws TweetException {

    long sinceId = lastSeenMention();
    try {//from ww  w.jav a 2s.  c  o m
        LOG.info("Checking for new Twitter mentions of {} since Tweet {}", myScreenName, sinceId);
        Paging paging = new Paging(sinceId);
        ResponseList<Status> mentions = twitterClient.getMentionsTimeline(paging);
        int numberOfMentions = mentions.size();
        LOG.info("Found {} new mentions", numberOfMentions);
        for (Status status : mentions) {
            User user = status.getUser();
            String mentionSummary = format("Date:%s, ID:%s, From:%s (%s), Text:'%s'", status.getCreatedAt(),
                    status.getId(), user.getScreenName(), user.getName(), status.getText());
            LOG.debug("New mention: [{}]", mentionSummary);
        }
        return mentions;
    } catch (TwitterException e) {
        throw new TweetException("Error getting Twitter mentions", e);
    }

    // TODO handle paging
}

From source file:com.mycompany.twitterapp.TwitterApp.java

public void getTimeline() {
    Set<String> keySet = listOfPeople.keySet();
    for (String key : keySet) {
        System.out.println("Debug Person - " + key);
        try {/* ww w.  j a  v  a  2 s . c  o  m*/
            List<Status> statuses = null;
            for (int i = 1; i < 16; i++) {
                statuses = twitter.getUserTimeline(key, new Paging(i));
                System.out.println("Debug - filling statuses = " + i + " - Size: " + statuses.size());

                if (statuses.size() < 1 || statuses == null) {
                    System.out.println("List Empty.");
                    break;
                }
                //System.out.println("Showing @" + statuses.get(0).getUser().getScreenName() + "'s home timeline.");
                for (Status status : statuses) {
                    //                        System.out.println("Debug - text: " + status.getText());
                    saveToFile(status.getUser().getId(), status.getText().replaceAll("\n", "\\\\n"),
                            status.getUser().getScreenName(), listOfPeople.get(key));
                    //                        System.out.println("debug - truncated: " + status.isTruncated());
                }
            }
            if (statuses.size() < 1 || statuses == null) {
                continue;
            }
            Status temp = statuses.get(0);
            saveToFile(temp.getUser().getId(), temp.getUser().getScreenName(), listOfPeople.get(key));
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to get timeline: " + te.getMessage());
            System.exit(-1);
        }
    }

}

From source file:com.test.GetDirectMessages.java

License:Apache License

/**
 * Usage: java twitter4j.examples.directmessage.GetDirectMessages
 *
 * @param args String[]//from   w w  w.  j  av  a  2  s  . c om
 */
public static void main(String[] args) {
    //        Twitter twitter = new TwitterFactory().getInstance();
    Twitter twitter = AccountTwitterFactory.getWiseManTwitter();
    try {
        Paging paging = new Paging(1);
        List<DirectMessage> messages;
        do {
            messages = twitter.getDirectMessages(paging);
            for (DirectMessage message : messages) {
                System.out.println("From: @" + message.getSenderScreenName() + " id:" + message.getId() + " - "
                        + message.getText());
            }
            paging.setPage(paging.getPage() + 1);
        } while (messages.size() > 0 && paging.getPage() < 10);
        System.out.println("done.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get messages: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:com.twitstreet.twitter.TwitterProxyImpl.java

License:Open Source License

@Override
public Date getFirstTweetDate(long stockId) {
    ResponseList<Status> respList;
    try {//  w w  w  . j  a  v a  2 s .  c  om
        Paging paging = new Paging(1l);
        respList = twitter.getUserTimeline(stockId, paging);

        return respList.get(0).getCreatedAt();

    } catch (TwitterException e) {
        handleError(e);

    }

    return null;

}

From source file:examples.GetUserListStatuses.java

License:Apache License

/**
 * Usage: java twitter4j.examples.list.GetUserListStatuses [list id]
 *
 * @param args message//from   w w w . j  a v  a  2  s  . c om
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.list.GetUserListStatuses [list id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        Paging page = new Paging(1);
        ResponseList<Status> statuses;
        do {
            statuses = twitter.getUserListStatuses(Integer.parseInt(args[0]), page);
            for (Status status : statuses) {
                System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
            }
            page.setPage(page.getPage() + 1);
        } while (statuses.size() > 0 && page.getPage() <= 10);
        System.out.println("done.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to list statuses: " + te.getMessage());
        System.exit(-1);
    }
}