List of usage examples for twitter4j.conf ConfigurationBuilder ConfigurationBuilder
ConfigurationBuilder
From source file:com.carolinarollergirls.scoreboard.viewer.TwitterViewer.java
License:GNU General Public License
private ConfigurationBuilder getConfigurationBuilder() { return new ConfigurationBuilder().setDebugEnabled(false).setUserStreamRepliesAllEnabled(false) .setOAuthConsumerKey("LcSklLv7gic519YE5ylK1g") .setOAuthConsumerSecret("BXjvuTrbl6rTIgybxqCTIfZS7obv2OdUYiM1n8V3Q"); }
From source file:com.cask.twitter.TweetStream.java
License:Apache License
@Override public void initialize(FlowletContext context) { statusListener = new StatusListener() { @Override// w w w .jav a2 s . com public void onStatus(Status status) { for (HashtagEntity hash : status.getHashtagEntities()) { tweetQ.add(hash.getText()); } } @Override public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { } @Override public void onTrackLimitationNotice(int i) { } @Override public void onScrubGeo(long l, long l2) { } @Override public void onStallWarning(StallWarning stallWarning) { } @Override public void onException(Exception e) { LOG.error(e.getMessage()); } }; cb = new ConfigurationBuilder(); cb.setDebugEnabled(false) //Provide Twitter Credentials through Runtime Arguments. .setOAuthConsumerKey(context.getRuntimeArguments().get("ConsumerKey")) .setOAuthConsumerSecret(context.getRuntimeArguments().get("ConsumerSecret")) .setOAuthAccessToken(context.getRuntimeArguments().get("AccessToken")) .setOAuthAccessTokenSecret(context.getRuntimeArguments().get("AccessTokenSecret")); tStream = new TwitterStreamFactory(cb.build()).getInstance(); //For testing, we can disable Twitter Stream and use testStream to send sample hashTags. if (!context.getRuntimeArguments().containsKey("disableLiveStream")) { tStream.addListener(statusListener); tStream.sample(); } }
From source file:com.chimpler.example.TwitterStatusProducer.java
License:Apache License
public synchronized void startSample(String username, String password) { if (twitterStream != null) { return;// w w w . j av a2 s .c om } TwitterStreamFactory factory = new TwitterStreamFactory( new ConfigurationBuilder().setUser(username).setPassword(password).build()); twitterStream = factory.getInstance(); twitterStream.addListener(new StatusAdapter() { public void onStatus(Status status) { Map<String, Object> map = new HashMap<String, Object>(); map.put("status", "OK"); map.put("createdAt", status.getCreatedAt().toString()); map.put("username", status.getUser().getName()); map.put("profileImageUrl", status.getUser().getMiniProfileImageURL()); map.put("text", status.getText()); cometTwitterService.publishMessage(map, Long.toString(status.getId())); } @Override public void onException(Exception ex) { Map<String, Object> map = new HashMap<String, Object>(); map.put("status", "ERR"); map.put("text", ex.getMessage()); cometTwitterService.publishMessage(map, "-1"); stopSample(); } }); logger.log(Level.INFO, "Starting listening to twitter sample"); twitterStream.sample(); }
From source file:com.cloudera.flume.source.TwitterSource.java
License:Apache License
/** * The initialization method for the Source. The context contains all the * Flume configuration info, and can be used to retrieve any configuration * values necessary to set up the Source. *//* ww w.j a va 2 s.c o m*/ @Override public void configure(Context context) { consumerKey = context.getString(TwitterSourceConstants.CONSUMER_KEY_KEY); consumerSecret = context.getString(TwitterSourceConstants.CONSUMER_SECRET_KEY); accessToken = context.getString(TwitterSourceConstants.ACCESS_TOKEN_KEY); accessTokenSecret = context.getString(TwitterSourceConstants.ACCESS_TOKEN_SECRET_KEY); String keywordString = context.getString(TwitterSourceConstants.KEYWORDS_KEY, ""); keywords = keywordString.split(","); for (int i = 0; i < keywords.length; i++) { keywords[i] = keywords[i].trim(); } ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setOAuthConsumerKey(consumerKey); cb.setOAuthConsumerSecret(consumerSecret); cb.setOAuthAccessToken(accessToken); cb.setOAuthAccessTokenSecret(accessTokenSecret); cb.setJSONStoreEnabled(true); cb.setIncludeEntitiesEnabled(true); twitterStream = new TwitterStreamFactory(cb.build()).getInstance(); }
From source file:com.cruta.hecas.twitter.MyTwitter.java
public void Tweet() { try {/*from ww w . ja va2 s . co m*/ System.out.println("voy a enviar"); Twitter twitter; ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("4W5InvFtHgtZAQBa6QQeQFWlA") .setOAuthConsumerSecret("t3nCC1RKhAcqjZPoHmF4Osa2VzY9kTBt0d4XAn00H49jXHtfgT") .setOAuthAccessToken("15616431-NXjouNhzTBYQYQqRHPJnMKakh0RyZSHvhss7RYrTm") .setOAuthAccessTokenSecret("gC1hIbqXOU8QYjjcyYKL8P2uW2wVzSu3X5TfBO3iMqdo2"); twitter = new TwitterFactory(cb.build()).getInstance(); Paging pagina = new Paging(); Status tweetEscrito = twitter.updateStatus("Holas desde hecas"); System.out.println("twett enviado"); } catch (Exception ex) { JSFUtil.errorDialog("Tweet()", ex.getLocalizedMessage()); System.out.println("error() " + ex.getLocalizedMessage()); } }
From source file:com.cruta.hecas.twitter.MyTwitter.java
public void Tweet(String mensaje) { try {//w w w . j a v a 2s . co m Twitter twitter; ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("4W5InvFtHgtZAQBa6QQeQFWlA") .setOAuthConsumerSecret("t3nCC1RKhAcqjZPoHmF4Osa2VzY9kTBt0d4XAn00H49jXHtfgT") .setOAuthAccessToken("15616431-NXjouNhzTBYQYQqRHPJnMKakh0RyZSHvhss7RYrTm") .setOAuthAccessTokenSecret("gC1hIbqXOU8QYjjcyYKL8P2uW2wVzSu3X5TfBO3iMqdo2"); twitter = new TwitterFactory(cb.build()).getInstance(); Paging pagina = new Paging(); Status tweetEscrito = twitter.updateStatus(mensaje); System.out.println("twett enviado"); } catch (Exception ex) { JSFUtil.errorDialog("Tweet()", ex.getLocalizedMessage()); System.out.println("tweet() " + ex.getLocalizedMessage()); } }
From source file:com.daemon.TwitterProfile.java
License:Open Source License
public TwitterProfile(String name, String screenName, String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret, DaemonProperties properties) { _profileName = name;//from w w w . j av a 2 s . co m _screenName = screenName; _consumerKey = consumerKey; _consumerSecret = consumerSecret; _accessToken = accessToken; _accessTokenSecret = accessTokenSecret; _props = properties; // Create Twitter object ConfigurationBuilder conf = new ConfigurationBuilder(); conf.setOAuthAccessToken(getAccessToken()).setOAuthAccessTokenSecret(getAccessTokenSecret()) .setOAuthConsumerKey(getConsumerKey()).setOAuthConsumerSecret(getConsumerSecret()); _twitter = new TwitterFactory(conf.build()).getInstance(); }
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); }// ww w .ja v a 2 s .c om 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(); }