/** * Remove all user lists irrelevant of creation date since that information is not exposed via * twitter/ twitter4j. Note: Not time aware. */ private void removeLists() { try { ResponseList<UserList> lists = twitter.getUserLists(twitter.getScreenName()); for (UserList list : lists) { twitter.destroyUserList(list.getId()); } } catch (TwitterException e) { logger.error("Twitter exception occurred", e); } }
/** * Usage: java twitter4j.examples.list.DestroyUserList [list id] * * @param args message */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.list.DestroyUserList [list id]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); UserList list = twitter.destroyUserList(Integer.parseInt(args[0])); System.out.println( "Successfully deleted the list (id:" + list.getId() + ", slug:" + list.getSlug() + ")."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to delete a list: " + te.getMessage()); System.exit(-1); } }