Example usage for twitter4j.conf ConfigurationBuilder setHttpProxyUser

List of usage examples for twitter4j.conf ConfigurationBuilder setHttpProxyUser

Introduction

In this page you can find the example usage for twitter4j.conf ConfigurationBuilder setHttpProxyUser.

Prototype

public ConfigurationBuilder setHttpProxyUser(String httpProxyUser) 

Source Link

Usage

From source file:it.greenvulcano.gvesb.social.twitter.TwitterSocialAdapterAccount.java

License:Open Source License

/**
 * This method returns the interface class towards Twitter, already instantiated with the
 * account's tokens/*from  w w  w  .j av a  2  s. c  o m*/
 * 
 * @return {@link Twitter}
 */
public Twitter getProxyObject() {
    if (twitter != null) {
        return twitter;
    } else {
        // setting OAuth tokens
        ConfigurationBuilder confBuilder = new ConfigurationBuilder();
        if (proxy != null) {
            confBuilder.setHttpProxyHost(proxy.getHttpProxyHost());
            confBuilder.setHttpProxyPort(proxy.getHttpProxyPort());
            confBuilder.setHttpProxyUser(proxy.getHttpProxyUser());
            confBuilder.setHttpProxyPassword(proxy.getHttpProxyPassword());
        }
        confBuilder.setOAuthConsumerKey(consumerKey);
        confBuilder.setOAuthConsumerSecret(consumerSecret);
        confBuilder.setOAuthAccessToken(accessToken);
        confBuilder.setOAuthAccessTokenSecret(accessTokenSecret);
        Configuration config = confBuilder.build();
        // instantiating Twitter object
        this.twitter = new TwitterFactory(config).getInstance();
    }
    logger.info("got TwitterFactory instance.");
    return twitter;
}

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 .j  av  a2 s .c o m
    }
    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.elasticsearch.river.twitter.TwitterRiver.java

License:Apache License

/**
 * Twitter Stream Builder/*from ww w. j a  va2 s  . c o m*/
 * @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.loklak.scraper.TwitterRiver.java

License:Apache License

/**
 * Build configuration object with credentials and proxy settings
 * @return/*from  w  w  w  .  j  av  a2  s  .co m*/
 */
private Configuration buildTwitterConfiguration() {
    logger.debug("creating twitter configuration");
    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);
    logger.debug("twitter configuration created");
    return cb.build();
}

From source file:org.mule.twitter.TwitterConnector.java

License:Open Source License

/**
 * Connects to Twitter/*from  w ww. ja v a2  s  .  c o  m*/
 * @param accessKey The access key provided by Twitter
 * @param accessSecret The access secret provided by Twitter
 * @throws ConnectionException when the connection fails
 */
@Connect
public void connect(@ConnectionKey String accessKey, String accessSecret) throws ConnectionException {
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setUseSSL(useSSL);
    cb.setHttpProxyHost(proxyHost);
    cb.setHttpProxyPort(proxyPort);
    cb.setHttpProxyUser(proxyUsername);
    cb.setHttpProxyPassword(proxyPassword);

    HttpClientHiddenConstructionArgument.setUseMule(true);
    twitter = new TwitterFactory(cb.build()).getInstance();

    twitter.setOAuthConsumer(consumerKey, consumerSecret);
    if (accessKey != null) {
        twitter.setOAuthAccessToken(new AccessToken(accessKey, accessSecret));
        setAccessToken(accessKey);
        setAccessTokenSecret(accessSecret);
    }
}