twitterStream = new TwitterStreamFactory().getInstance(); twitterStream.addConnectionLifeCycleListener(connectionLifeCycleListener); statusListener = new StatusListener()
@Override public void configure(Context context) { String consumerKey = context.getString("consumerKey"); String consumerSecret = context.getString("consumerSecret"); String accessToken = context.getString("accessToken"); String accessTokenSecret = context.getString("accessTokenSecret"); twitterStream = new TwitterStreamFactory().getInstance(); twitterStream.setOAuthConsumer(consumerKey, consumerSecret); twitterStream.setOAuthAccessToken(new AccessToken(accessToken, accessTokenSecret)); twitterStream.addListener(this); avroSchema = createAvroSchema(); dataFileWriter = new DataFileWriter<GenericRecord>( new GenericDatumWriter<GenericRecord>(avroSchema)); maxBatchSize = context.getInteger("maxBatchSize", maxBatchSize); maxBatchDurationMillis = context.getInteger("maxBatchDurationMillis", maxBatchDurationMillis); }
TwitterStream twitterStream = new TwitterStreamFactory().getInstance();
TwitterStream ts = new TwitterStreamFactory().getInstance();
TwitterStream twitterStream = new TwitterStreamFactory().getInstance();
cb.setDebugEnabled(false); twitterStream = new TwitterStreamFactory(cb.build()).getInstance(); StatusListener listener = new StatusListener() { @Override
StatusListener listener = new MyStatusListener(); TwitterStream twitterStream = new TwitterStreamFactory().getInstance(); twitterStream.addListenter(listener);
@Override public void setup(OperatorContext context) { operatorThread = Thread.currentThread(); if (feedMultiplier != 1) { logger.info("Load set to be {}% of the entire twitter feed", feedMultiplier); } ConfigurationBuilder cb = setupConfigurationBuilder(); ts = new TwitterStreamFactory(cb.build()).getInstance(); }
@Override public void setup(OperatorContext context) { operatorThread = Thread.currentThread(); if (feedMultiplier != 1) { logger.info("Load set to be {}% of the entire twitter feed", feedMultiplier); } ConfigurationBuilder cb = setupConfigurationBuilder(); ts = new TwitterStreamFactory(cb.build()).getInstance(); }
public TwitterStream createTwitterStream() { if (twitterStream == null) { twitterStream = new TwitterStreamFactory(getConfiguration()).getInstance(); } return twitterStream; }
public static TwitterStream getTwitterStream(Map<String, String> configuration) { ConfigurationBuilder cb = getAuthConfiguration(configuration); TwitterStreamFactory factory = new TwitterStreamFactory(cb.build()); return factory.getInstance(); }
public TwitterReceiver(StorageLevel storageLevel) { super(storageLevel); checkArgument(StorageLevel.MEMORY_ONLY().equals(storageLevel), String.format("Only [%s] supported.", StorageLevel.MEMORY_ONLY().toString())); twitterStream = new TwitterStreamFactory().getInstance(); }
public static void main(String[] args) throws TwitterException, IOException{ StatusListener listener = new StatusListener(){ public void onStatus(Status status) { System.out.println(status.getUser().getName() + " : " + status.getText()); } public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {} public void onTrackLimitationNotice(int numberOfLimitedStatuses) {} public void onException(Exception ex) { ex.printStackTrace(); } }; TwitterStream twitterStream = new TwitterStreamFactory().getInstance(); twitterStream.addListener(listener); // sample() method internally creates a thread which manipulates TwitterStream and calls these adequate listener methods continuously. twitterStream.sample(); }
@Override public void feedStatus(final PicSlurper slurper) { final StatusListener listener = new PriorityQueueStatusListener(slurper); final TwitterStream twitterStream = new TwitterStreamFactory().getInstance(accessToken); twitterStream.addListener(listener); twitterStream.sample(); } }
/** * * @param kafkaHost the host * @param kafkaTopic the topic name on which to publish the tweets * @param kafkaPort the port for Kafka clients to connect */ public TweetIngestor(String kafkaHost,String kafkaTopic, int kafkaPort, String track, double tweetRate) { TwitterStreamFactory fact = new TwitterStreamFactory(); checkState(fact.getInstance().getConfiguration().isJSONStoreEnabled(), "Twitter4j JSON store is disabled. You must enabled it in the twitter4j.properties file!"); stream = fact.getInstance(); poster = new RemoteKafkaPoster(METRIC_REGISTRY, kafkaHost, kafkaPort); this.kafkaTopic = kafkaTopic; this.rateLimiter = RateLimiter.create(tweetRate); this.track = track; }
private void setUpTwitterConnection() { ConfigurationBuilder cb = setupConfigurationBuilder(); ts = new TwitterStreamFactory(cb.build()).getInstance(); ts.addListener(TwitterSampleInput.this); // we can only listen to tweets containing links by callng ts.links(). // it seems it requires prior signed agreement with twitter. ts.sample(); }
private void setUpTwitterConnection() { ConfigurationBuilder cb = setupConfigurationBuilder(); ts = new TwitterStreamFactory(cb.build()).getInstance(); ts.addListener(TwitterSampleInput.this); // we can only listen to tweets containing links by callng ts.links(). // it seems it requires prior signed agreement with twitter. ts.sample(); }
private Observable<Status> status() { return Observable.create(subscriber -> { System.out.println("Establishing connection"); TwitterStream twitterStream = new TwitterStreamFactory().getInstance(); //... subscriber.add(Subscriptions.create(() -> { System.out.println("Disconnecting"); twitterStream.shutdown(); })); twitterStream.sample(); }); }
public static void main(String[] args) throws IOException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey("*********") .setOAuthConsumerSecret("************") .setOAuthAccessToken("*******************") .setOAuthAccessTokenSecret("****************"); TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance(); TwitterDownloader td = new TwitterDownloader(); StatusListener listener = td.makeListener(twitterStream); twitterStream.addListener(listener); twitterStream.sample(); }
public TwitterStream newStream() { ConfigurationBuilder cb = new ConfigurationBuilder() .setUseSSL(useSSL) .setOAuthConsumerKey(consumerKey) .setOAuthConsumerSecret(consumerSecret) .setStreamBaseURL(getStreamBaseUrl()) .setSiteStreamBaseURL(getSiteStreamBaseUrl()) .setHttpProxyHost(proxyHost) .setHttpProxyPort(proxyPort) .setHttpProxyUser(proxyUsername) .setHttpProxyPassword(proxyPassword); if (getAccessToken() != null) { cb.setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessTokenSecret); } HttpClientHiddenConstructionArgument.setUseMule(false); return new TwitterStreamFactory(cb.build()).getInstance(); }