Search in sources :

Example 1 with LoadTwitterFunction

use of org.talend.spark.function.LoadTwitterFunction in project tdi-studio-se by Talend.

the class TwitterLoad method twitterStream.

public static JavaDStream<List<Object>> twitterStream(JavaStreamingContext ctx, String username, String password, String accessToken, String secretToken, String[] filters, List<TwitterParameter> twitterParameters) {
    twitter4j.conf.ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setOAuthAccessToken(accessToken);
    builder.setOAuthAccessTokenSecret(secretToken);
    builder.setOAuthConsumerKey(username);
    builder.setOAuthConsumerSecret(password);
    JavaDStream<Status> inputDStream = null;
    if (filters.length > 0) {
        if (filters.length == 1 && filters[0].equals(""))
            inputDStream = TwitterUtils.createStream(ctx, new OAuthAuthorization(builder.build()));
        else
            inputDStream = TwitterUtils.createStream(ctx, new OAuthAuthorization(builder.build()), filters);
        return inputDStream.map(new LoadTwitterFunction(twitterParameters));
    }
    return null;
}
Also used : Status(twitter4j.Status) ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) LoadTwitterFunction(org.talend.spark.function.LoadTwitterFunction) OAuthAuthorization(twitter4j.auth.OAuthAuthorization)

Aggregations

LoadTwitterFunction (org.talend.spark.function.LoadTwitterFunction)1 Status (twitter4j.Status)1 OAuthAuthorization (twitter4j.auth.OAuthAuthorization)1 ConfigurationBuilder (twitter4j.conf.ConfigurationBuilder)1