Created
May 8, 2012 14:51
-
-
Save takawitter/2635862 to your computer and use it in GitHub Desktop.
workaround for http://jira.twitter4j.org/browse/TFJ-556
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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