|
Project Information
Links
|
This is a Java binding for the Twitter API written in a way that will allow Java developers to quickly and successfully work with the Twitter API. (Uses OAuth authentication.) TwitterStreamConfiguration tws = new TwitterStreamConfiguration(KEY, SECRET); tws.getAuthorizationUrl(); // URL to visit for PIN tws.authorize(pin); // enter the pin from the site tws.getToken(); tws.getTokenSecret(); // hold onto these MyTwitterHandler handler = new MyTwitterHandler(); TwitterStream ts = TweetRiver.sample(tws, handler); (new Thread(ts)).start(); And a TwitterStreamHandler handles incoming actions: class MyTwitterHandler implements TwitterStreamHandler {
public void addTweet(STweet t) {
System.out.println("TWEET! " + t.toString());
}
public void addLimit(STweet l) {
System.out.println("LIMIT! " + l.toString());
}
public void addDeletion(SDeletion d) {
System.out.println("DELETION! " + d.toString());
}
public void stop() {
System.out.println("Stopped.");
}
}
|