List of usage examples for twitter4j.conf ConfigurationBuilder setDebugEnabled
public ConfigurationBuilder setDebugEnabled(boolean debugEnabled)
From source file:com.daiv.android.twitter.utils.Utils.java
License:Apache License
public static TwitterStream getStreamingTwitter(Context context, AppSettings settings) { settings = AppSettings.getInstance(context); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY) .setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET) .setOAuthAccessToken(settings.authenticationToken) .setOAuthAccessTokenSecret(settings.authenticationTokenSecret); TwitterStreamFactory tf = new TwitterStreamFactory(cb.build()); return tf.getInstance(); }
From source file:com.daiv.android.twitter.utils.Utils.java
License:Apache License
public static Twitter getSecondTwitter(Context context) { AppSettings settings = AppSettings.getInstance(context); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY) .setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET) .setOAuthAccessToken(settings.secondAuthToken) .setOAuthAccessTokenSecret(settings.secondAuthTokenSecret); TwitterFactory tf = new TwitterFactory(cb.build()); return tf.getInstance(); }
From source file:com.datatorrent.contrib.twitter.TwitterSampleInput.java
License:Open Source License
@Override public void setup(OperatorContext context) { operatorThread = Thread.currentThread(); if (feedMultiplier != 1) { logger.info("Load set to be {}% of the entire twitter feed", feedMultiplier); }/*from w w w . j av a 2s .c o m*/ ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(debug).setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret) .setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessTokenSecret); ts = new TwitterStreamFactory(cb.build()).getInstance(); }
From source file:com.datatorrent.contrib.twitter.TwitterSampleInput.java
License:Open Source License
private void setUpTwitterConnection() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(debug).setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret) .setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessTokenSecret); 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();/*from w ww.j a v a 2s .c om*/ }
From source file:com.datatorrent.demos.twitter.TwitterSampleInput.java
License:Open Source License
@Override public void setup(OperatorContext context) { if (multiplier != 1) { logger.info("Load set to be {}% of the entire twitter feed", multiplier); }/* ww w . j ava2s . c o m*/ ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(debug).setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret) .setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessTokenSecret); ts = new TwitterStreamFactory(cb.build()).getInstance(); }
From source file:com.dhamacher.sentimentanalysis4tweets.twitterapi.TweetOperator.java
License:Apache License
private Configuration buildConfig() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) /**// w w w. ja v a2 s . c o m * Go to https://dev.twitter.com/ -> Sign in -> create App -> * use the data given at the end of App creation You need: (1) * Consumer Key (2) Consumer Secret (3) Access Token (4) Access * Token Secret */ .setOAuthConsumerKey(CONSUMER_KEY).setOAuthConsumerSecret(CONSUMER_SECRET) .setOAuthAccessToken(ACCESS_TOKEN).setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET); return cb.build(); }
From source file:com.dhamacher.tweetsentimentanalysis.Main.java
License:Open Source License
private static Configuration buildConfig() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) /**/*from w w w .j a va2 s.c o m*/ * Go to https://dev.twitter.com/ -> Sign in -> create App * -> use the data given at the end of App creation * You need: * (1) Consumer Key * (2) Consumer Secret * (3) Access Token * (4) Access Token Secret */ .setOAuthConsumerKey("*************************") .setOAuthConsumerSecret("****************************") .setOAuthAccessToken("***************************************") .setOAuthAccessTokenSecret("****************************************"); return cb.build(); }
From source file:com.dvd.codechallenge.Challengue.java
public static Tweets getTweets(String user) throws TwitterException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("sMYxrCslzDDHGhFn5MSvPMWhw") .setOAuthConsumerSecret("ip8E4OoTGNQetDHz8oTereIsXAnO2cGlgs7Dd2S4lXti4weHAt") .setOAuthAccessToken("451175684-DBydPtZsitmr6EHPVansnVygQXRALCCKnKUqUa4W") .setOAuthAccessTokenSecret("prPHOfZj3IMFrW7ToFbKWJkRjWHM2qlpUdSecEZyuhLvd"); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance();/*from w w w .j a v a2 s . co m*/ List<Status> statuses = twitter.getUserTimeline(user); // System.out.println("Tweets recuperados"); // statuses.forEach(x -> System.out.println(x.getUser().getName() // + "-> " + x.getUser().getScreenName() + ":::" // + x.getText())); Tweets ts = new Tweets(); statuses.forEach(x -> ts.addTweet(x.getText())); return ts; }
From source file:com.ebay.pulsar.twittersample.channel.TwitterSampleChannel.java
License:GNU General Public License
@Override public void open() throws EventException { super.open(); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(false); twitterStream = new TwitterStreamFactory(cb.build()).getInstance(); StatusListener listener = new StatusListener() { @Override//from w ww. j a v a 2s . c om public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { } @Override public void onException(Exception ex) { ex.printStackTrace(); } @Override public void onScrubGeo(long userId, long upToStatusId) { } @Override public void onStallWarning(StallWarning warning) { } @Override public void onStatus(Status status) { HashtagEntity[] hashtagEntities = status.getHashtagEntities(); JetstreamEvent event = new JetstreamEvent(); event.setEventType("TwitterSample"); Place place = status.getPlace(); if (place != null) { event.put("country", place.getCountry()); } event.put("ct", status.getCreatedAt().getTime()); event.put("text", status.getText()); event.put("lang", status.getLang()); event.put("user", status.getUser().getName()); if (hashtagEntities != null && hashtagEntities.length > 0) { StringBuilder s = new StringBuilder(); s.append(hashtagEntities[0].getText()); for (int i = 1; i < hashtagEntities.length; i++) { s.append(","); s.append(hashtagEntities[i].getText()); } event.put("hashtag", s.toString()); } fireSendEvent(event); } @Override public void onTrackLimitationNotice(int numberOfLimitedStatuses) { } }; twitterStream.addListener(listener); twitterStream.sample(); }
From source file:com.esri.geoevent.transport.twitter.TwitterInboundTransport.java
License:Apache License
private void receiveData() { try {// w w w .j a va2s. co m applyProperties(); setRunningState(RunningState.STARTED); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true); cb.setOAuthConsumerKey(consumerKey); cb.setOAuthConsumerSecret(consumerSecret); cb.setOAuthAccessToken(accessToken); cb.setOAuthAccessTokenSecret(accessTokenSecret); twitterStream = new TwitterStreamFactory(cb.build()).getInstance(); RawStreamListener rl = new RawStreamListener() { @Override public void onException(Exception ex) { LOGGER.error("INBOUND_TRANSPORT_RAW_STREAM_LISTERNER_EXCEPTION", ex.getMessage()); } @Override public void onMessage(String rawString) { receive(rawString); } }; FilterQuery fq = new FilterQuery(); String keywords[] = tracks; if (follows != null && follows.length > 0) fq.follow(follows); else if (keywords != null && keywords.length > 0) fq.track(keywords); else if (locations != null) fq.locations(locations); else throw new Exception("INBOUND_TRANSPORT_NOFILTER_ERROR"); fq.count(count); LOGGER.info("INBOUND_TRANSPORT_FILTER", filterString); twitterStream.addListener(rl); twitterStream.filter(fq); } catch (Throwable ex) { LOGGER.error("UNEXPECTED_ERROR", ex); setRunningState(RunningState.ERROR); } }