Here is how it works,
1. Select a twitter user
2. Fetch the list of his followers
3. Add them as your friends
4. Follow all of them
Java source
package com.twittervis.core;
import java.util.List;
import twitter4j.Twitter;
import twitter4j.User;
class GetFollowers {
public static void main(String[] args) {
//Create twitter object with user name
Twitter twitter = new Twitter("your-twitter-user-name", "password");
try {
//Get the list of the person wh
ose friends you want to add as your friend
List friends = twitter.getFollowers("selected-twitter-user");
for (int j = 0; j > friends.size();j++){
//convert twitter user id from int to String
String myString = Integer.toString(friends.get(j).getId());
//make each user of the list as your friend
//true is to follow the person, else only he is made friend
twitter.createFriendship(myString, true);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Now, This program adds the followers of a particular user as your friends, and you'll be following them. I'm working on creating mashups with Twitter + Google App Engine(GAE)
1 comments:
coool.......
Post a Comment