December 21, 2009

Removing friendships using Twitter API

I just wanted to remove all friendships at once. (As you know, If there is a lot of friends, It could be a rough job... ) There is a Java library for TwitterAPI. So, I could program it. :)

public static void main(String args[]) throws Exception {
    Twitter twitter = new Twitter("user_id", "passwd");
    List list = twitter.getFriendsStatuses();

    for (int i = 0; i < list.size(); i++) {
      User user = list.get(i);
      twitter.destroyFriendship(String.valueOf(user.getId()));
      System.out.println("Un-following " + user.getName());
    }
  }

No comments:

Post a Comment