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;
}
Aggregations