List of usage examples for twitter4j.conf ConfigurationBuilder build
public Configuration build()
From source file:com.daiv.android.twitter.utils.Utils.java
License:Apache License
public static Twitter getTwitter(Context context, AppSettings settings) { if (settings == null) { settings = AppSettings.getInstance(context); }//from ww w . ja va2s .c o m ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY) .setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET) .setOAuthAccessToken(settings.authenticationToken) .setOAuthAccessTokenSecret(settings.authenticationTokenSecret); TwitterFactory tf = new TwitterFactory(cb.build()); return tf.getInstance(); }
From source file:com.daiv.android.twitter.utils.Utils.java
License:Apache License
public static Twitter getTwitter(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.authenticationToken) .setOAuthAccessTokenSecret(settings.authenticationTokenSecret); TwitterFactory tf = new TwitterFactory(cb.build()); return tf.getInstance(); }
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.data.dataanalytics.twitter.TwitterFeed.java
private static OAuth2Token getOAuth2Token() { OAuth2Token token = null;/* w w w.j a v a 2 s. c o m*/ ConfigurationBuilder cb; cb = new ConfigurationBuilder(); cb.setApplicationOnlyAuthEnabled(true); cb.setOAuthConsumerKey(CONSUMER_KEY).setOAuthConsumerSecret(CONSUMER_SECRET); try { token = new TwitterFactory(cb.build()).getInstance().getOAuth2Token(); } catch (Exception e) { System.out.println("Could not get OAuth2 token"); e.printStackTrace(); System.exit(0); } return token; }
From source file:com.data.dataanalytics.twitter.TwitterFeed.java
/** * Get a fully application-authenticated Twitter object useful for making subsequent calls. * *//*from w w w . ja va 2 s . c o m*/ protected static twitter4j.Twitter getTwitter() { OAuth2Token token; // First step, get a "bearer" token that can be used for our requests token = getOAuth2Token(); // Now, configure our new Twitter object to use application authentication and provide it with // our CONSUMER key and secret and the bearer token we got back from Twitter ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setApplicationOnlyAuthEnabled(true); cb.setOAuthConsumerKey(CONSUMER_KEY); cb.setOAuthConsumerSecret(CONSUMER_SECRET); cb.setOAuth2TokenType(token.getTokenType()); cb.setOAuth2AccessToken(token.getAccessToken()); // Create the Twitter object return new TwitterFactory(cb.build()).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 a v 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();/* www . j av a 2s . co m*/ }
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 .java 2 s . co 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)/*from w w w .j a v a 2 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(); }