Twitter Stream filter - Java Social Media

Java examples for Social Media:Twitter

Description

Twitter Stream filter

Demo Code



import twitter4j.*;
import twitter4j.auth.AccessToken;

import java.io.IOException;


public class TwitterApp {

    public static void main(String[] args) throws IOException {
        TwitterStream stream = TwitterStreamFactory.getSingleton();
        stream.setOAuthConsumer("", "");
        stream.setOAuthAccessToken(new AccessToken("", ""));

        stream.addListener(new UserStreamAdapter() {

            @Override//  w w  w .j a  va  2 s  . c  om
            public void onStatus(Status status) {
                
                System.out.println(status.getUser().getScreenName());
                System.out.println(status.getText());
                
            }
        });

        stream.filter(new FilterQuery().track("ahok"));
        System.in.read();
    }

}

Related Tutorials