List of usage examples for twitter4j.conf ConfigurationBuilder ConfigurationBuilder
ConfigurationBuilder
From source file:org.bonitasoft.connectors.twitter.TwitterConnector.java
License:Open Source License
@Override protected void executeConnector() throws Exception { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); if (getProxyHost() != null && getProxyPort() != null) { configurationBuilder.setHttpProxyHost(getProxyHost()); configurationBuilder.setHttpProxyPort(getProxyPort()); if (getProxyUser() != null && getProxyPass() != null) { configurationBuilder.setHttpProxyUser(getProxyUser()); configurationBuilder.setHttpProxyPassword(getProxyPass()); }//from w w w . ja v a2s . c om } Configuration configuration = new ConfigurationBuilder().build(); AccessToken token = new AccessToken(accessToken, accessTokenSecret); OAuthAuthorization authorization = new OAuthAuthorization(configuration, consumerKey, consumerSecret, token); Twitter twitter = new TwitterFactory().getInstance(authorization); executeTask(twitter); }
From source file:org.botlibre.sense.twitter.Twitter.java
License:Open Source License
public void connect() throws TwitterException { initProperties();// www. j a v a 2s . co m ConfigurationBuilder config = new ConfigurationBuilder(); config.setOAuthConsumerKey(getOauthKey()); config.setOAuthConsumerSecret(getOauthSecret()); config.setOAuthAccessToken(getToken()); config.setOAuthAccessTokenSecret(getTokenSecret()); twitter4j.Twitter twitter = new TwitterFactory(config.build()).getInstance(); User user = twitter.verifyCredentials(); if (!this.userName.equals(user.getScreenName())) { this.userName = user.getScreenName(); saveProperties(null); } //AccessToken accessToken = new AccessToken(getToken(), getTokenSecret()); //twitter4j.Twitter twitter = new TwitterFactory().getInstance(accessToken); //twitter4j.Twitter twitter = new TwitterFactory().getInstance(getOauthKey(), getOauthSecret(), accessToken); //twitter4j.Twitter twitter = new TwitterFactory().getInstance(getUsername(), getPassword()); setConnection(twitter); }
From source file:org.brunocvcunha.taskerbox.impl.twitter.TwitterChannel.java
License:Apache License
@Override public void setup() throws IllegalStateException, TwitterException { logInfo(log, "Twitter setup..."); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(this.consumerKey).setOAuthConsumerSecret(this.consumerSecret) .setOAuthAccessToken(this.accessToken).setOAuthAccessTokenSecret(this.accessTokenSecret); TwitterFactory tf = new TwitterFactory(cb.build()); this.twitter = tf.getInstance(); this.loggedUser = this.twitter.getScreenName(); logInfo(log, "Twitter setup finished! Logged user is " + this.loggedUser); }
From source file:org.btcwolf.twitter.TwitterAgent.java
License:Open Source License
public TwitterAgent() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(SettingsProvider.getProperty(CONSUMER_KEY)) .setOAuthConsumerSecret(SettingsProvider.getProperty(CONSUMER_SECRET)) .setOAuthAccessToken(SettingsProvider.getProperty(ACCESS_TOKEN)) .setOAuthAccessTokenSecret(SettingsProvider.getProperty(TOKEN_SECRET)); this.twitter = new TwitterFactory(cb.build()); }
From source file:org.codice.ddf.catalog.twitter.source.TwitterSource.java
License:Open Source License
public void init() { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); Configuration configuration = configurationBuilder.setOAuthConsumerKey(consumerKey) .setOAuthConsumerSecret(consumerSecret).setApplicationOnlyAuthEnabled(true).build(); twitterFactory = new TwitterFactory(configuration); }
From source file:org.craftercms.cstudio.publishing.processor.TwitterPostProcessor.java
License:Open Source License
/** * factory method for twitter upload instance. Override if you want to authenticate differently * @return twitter uploader instance/*ww w .j a v a 2 s. c o m*/ */ protected ImageUpload getTwitterUploaderInstance() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setDebugEnabled(true).setOAuthConsumerKey(consumerKeyStr).setOAuthConsumerSecret(consumerSecretStr) .setOAuthAccessToken(accessTokenStr).setOAuthAccessTokenSecret(accessTokenSecretStr); Configuration configuration = builder.build(); OAuthAuthorization auth = new OAuthAuthorization(configuration); ImageUpload uploader = new ImageUploadFactory(configuration).getInstance(auth); return uploader; }
From source file:org.craftercms.cstudio.publishing.processor.TwitterPostProcessor.java
License:Open Source License
/** * factory method for twitter instance. Override if you want to authenticate differently * @return twitter instance//from w w w .j ava 2 s .c o m */ protected Twitter getTwitterInstance() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setDebugEnabled(true).setOAuthConsumerKey(consumerKeyStr).setOAuthConsumerSecret(consumerSecretStr) .setOAuthAccessToken(accessTokenStr).setOAuthAccessTokenSecret(accessTokenSecretStr); Configuration configuration = builder.build(); TwitterFactory factory = new TwitterFactory(configuration); Twitter twitter = factory.getInstance(); return twitter; }
From source file:org.csp.everyaware.internet.TwitterManager.java
License:Open Source License
public void initTwitter() { ConfigurationBuilder confbuilder = new ConfigurationBuilder(); Configuration conf = confbuilder.setOAuthConsumerKey(Constants.CONSUMER_KEY) .setOAuthConsumerSecret(Constants.CONSUMER_SECRET).build(); mTwitter = new TwitterFactory(conf).getInstance(); mTwitter.setOAuthAccessToken(null);//from w w w .ja v a2s. c o m //try //{ new OuthRequestTokenTask().execute(Constants.CALLBACK_URL); /* mRequestToken = mTwitter.getOAuthRequestToken(Constants.CALLBACK_URL); Intent intent = new Intent(mActivity, TwitterLogin.class); intent.putExtra(Constants.IEXTRA_AUTH_URL, mRequestToken.getAuthorizationURL()); mActivity.startActivityForResult(intent, 0);*/ /* } catch (TwitterException e) { e.printStackTrace(); }*/ }
From source file:org.elasticsearch.river.twitter.TwitterRiver.java
License:Apache License
/** * Twitter Stream Builder/*w ww.j a v a 2 s . com*/ * @return */ private TwitterStream buildTwitterStream() { logger.debug("creating TwitterStreamFactory"); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setOAuthConsumerKey(oauthConsumerKey).setOAuthConsumerSecret(oauthConsumerSecret) .setOAuthAccessToken(oauthAccessToken).setOAuthAccessTokenSecret(oauthAccessTokenSecret); if (proxyHost != null) cb.setHttpProxyHost(proxyHost); if (proxyPort != null) cb.setHttpProxyPort(Integer.parseInt(proxyPort)); if (proxyUser != null) cb.setHttpProxyUser(proxyUser); if (proxyPassword != null) cb.setHttpProxyPassword(proxyPassword); if (raw) cb.setJSONStoreEnabled(true); // We force SSL usage cb.setUseSSL(true); TwitterStream stream = new TwitterStreamFactory(cb.build()).getInstance(); stream.addListener(new StatusHandler()); return stream; }
From source file:org.encuestame.social.api.templates.TwitterAPITemplate.java
License:Apache License
/** * Create Twitter API instance./*from www .ja va 2 s. c o m*/ * @param consumerSecret * @param consumerKey */ @Deprecated public TwitterAPITemplate(final String consumerSecret, final String consumerKey, final String accessToken, final String secretToken) { Assert.notNull(consumerKey); Assert.notNull(consumerSecret); Assert.notNull(accessToken); Assert.notNull(secretToken); log.debug("consumer key " + consumerKey); log.debug("consumer secret " + consumerSecret); log.debug("secret TOKEN " + secretToken); log.debug("acces TOKEN " + accessToken); this.consumerKey = consumerKey; this.consumerSecret = consumerSecret; this.secretToken = secretToken; this.accessToken = accessToken; this.configurationBuilder = new ConfigurationBuilder(); this.configurationBuilder.setDebugEnabled(true).setOAuthConsumerKey(this.consumerKey) .setOAuthConsumerSecret(this.consumerSecret).setOAuthAccessToken(this.accessToken) .setOAuthAccessTokenSecret(this.secretToken); }