Example usage for twitter4j.conf ConfigurationBuilder setUserStreamBaseURL

List of usage examples for twitter4j.conf ConfigurationBuilder setUserStreamBaseURL

Introduction

In this page you can find the example usage for twitter4j.conf ConfigurationBuilder setUserStreamBaseURL.

Prototype

public ConfigurationBuilder setUserStreamBaseURL(String userStreamBaseURL) 

Source Link

Usage

From source file:com.mycompany.mech2015task.App.java

public static void main(String[] args) throws Exception {
    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setOAuthConsumerKey(CONSUMER_KEY);
    builder.setOAuthConsumerSecret(CONSUMER_SECRET);
    builder.setOAuthAccessToken(ACCESS_TOKEN);
    builder.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET);

    // ??Twitter4J??API???betastream.twitter.com???????
    builder.setUserStreamBaseURL("https://userstream.twitter.com/2/");

    // Configuration?
    Configuration configuration = builder.build();

    /*        Configuration configuration = new ConfigurationBuilder().setOAuthConsumerKey(CONSUMER_KEY)
        .setOAuthConsumerSecret(CONSUMER_SECRET)
        .setOAuthAccessToken(ACCESS_TOKEN)
        .setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET)
        .build();// www  . j  a  v  a2 s.  c om
    */
    TwitterStream twStream = new TwitterStreamFactory(configuration).getInstance();
    //TwitterStream twStream = new TwitterStreamFactory().getInstance();
    twStream.addListener(new MyStatusListener());
    twStream.user();
    //twStream.sample();
}