Skip to content

Instantly share code, notes, and snippets.

@takawitter
Created May 8, 2012 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takawitter/2635862 to your computer and use it in GitHub Desktop.
Save takawitter/2635862 to your computer and use it in GitHub Desktop.
// workaround for http://jira.twitter4j.org/browse/TFJ-556
System.setProperty("http.keepAlive", "false");
TwitterStream s = new TwitterStreamFactory().getInstance();
s.setOAuthConsumer("CONSUMER", "SECRET");
s.setOAuthAccessToken(new AccessToken("ACCESSTOKEN", "SECRET"));
s.addListener(new StatusAdapter(){
public void onStatus(Status status) {
System.out.println(String.format("[%s] @%s: %s"
, status.getCreatedAt()
, status.getUser().getScreenName()
, status.getText()));
}
});
s.filter(new FilterQuery().track(new String[]{"Good-looking guy"}));
Thread.sleep(50000);
System.out.println(new Date() + ": shutdown");
s.shutdown();
System.out.println(new Date() + ": shutdown done.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment