Example usage for twitter4j.conf ConfigurationBuilder setDebugEnabled

List of usage examples for twitter4j.conf ConfigurationBuilder setDebugEnabled

Introduction

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

Prototype

public ConfigurationBuilder setDebugEnabled(boolean debugEnabled) 

Source Link

Usage

From source file:org.bireme.interop.toJson.Twitter2Json.java

License:Open Source License

public Twitter2Json(final String userId, final Query query, final int total, final Date lowerDate,
        final boolean useRetweets) throws TwitterException {
    assert ((userId != null) || (query != null));
    assert ((total >= 1) || (lowerDate != null));

    final ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey("LmvfpL4pJE7PJr0CgJUuQKZOy")
            .setOAuthConsumerSecret("UP1VIf4K3jGDvOYYXh0zshHnuj8HSUMDTWlJEEhGMWIJHKGXSJ")
            .setOAuthAccessToken("2788081964-9C7j4ZBOsdIy9tmtMkong54QimvjkwopXdLqecm")
            .setOAuthAccessTokenSecret("swwqLPLWppweF3KRKe2zpU9qPNFDbsZm9OqQ5scX9vVCp");

    final Twitter twitter = new TwitterFactory(cb.build()).getInstance();

    this.loader = new TweetLoader(twitter, userId, query, total, lowerDate, useRetweets);
    next = getNext();/*ww w  . ja v a 2 s . com*/
}

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.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/*from www  .  j  av  a2  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. ja v a  2s  .  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.glassfish.jersey.sample.sse.TwitterBean.java

License:Open Source License

/**
 * Since twitter uses the v1.1 API we use twitter4j to get
 * the search results using OAuth/*from   w  ww. jav a  2 s.c o m*/
 * @return a JsonArray containing tweets
 * @throws TwitterException
 * @throws IOException
 */
public JsonArray getFeedData() throws TwitterException, IOException {

    Properties prop = new Properties();
    // try {
    //load a properties file
    prop.load(this.getClass().getResourceAsStream("twitter4j.properties"));

    //get the property value and print it out
    String consumerKey = prop.getProperty("oauth.consumerKey");
    String consumerSecret = prop.getProperty("oauth.consumerSecret");
    String accessToken = prop.getProperty("oauth.accessToken");
    String accessTokenSecret = prop.getProperty("oauth.accessTokenSecret");
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret)
            .setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessTokenSecret);

    TwitterFactory tf = new TwitterFactory(cb.build());

    Twitter twitter = tf.getInstance();

    Query query = new Query("glassfish");
    QueryResult result = twitter.search(query);

    JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder();
    for (Status status : result.getTweets()) {
        jsonArrayBuilder.add(Json.createObjectBuilder().add("text", status.getText()).add("created_at",
                status.getCreatedAt().toString()));

        System.out.println(
                "@" + status.getUser().getScreenName() + ":" + status.getText() + status.getCreatedAt());
    }

    return jsonArrayBuilder.build();
}

From source file:org.hubiquitus.hubotsdk.adapters.HTwitterAdapterInbox.java

License:Open Source License

/**
 * Function for tweet Streaming/*from   w ww  .  ja v  a2 s . c o  m*/
 */
private void stream() {
    /**
     * Configuration for access to twitter account
     */
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setUseSSL(true).setOAuthConsumerKey(consumerKey)
            .setOAuthConsumerSecret(consumerSecret).setOAuthAccessToken(twitterAccessToken)
            .setOAuthAccessTokenSecret(twitterAccessTokenSecret);

    //Instantiation of tweet stream
    twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
    StatusListener listener = new StatusListener() {
        public void onStatus(Status tweet) {
            String lang = tweet.getUser().getLang();
            //Set the filter for the language
            if ((langFilter == null) || (lang != null && lang.equalsIgnoreCase(langFilter))) {
                HMessage message = transformtweet(tweet);
                put(message);
            }
        }

        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
        }

        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
        }

        public void onScrubGeo(long userId, long upToStatusId) {
        }

        public void onException(Exception ex) {
            log.info("message: ", ex);
        }
    };

    FilterQuery fq = new FilterQuery();
    fq.track(tags.split(","));
    twitterStream.addListener(listener);
    twitterStream.filter(fq);
}

From source file:org.hubiquitus.hubotsdk.adapters.HTwitterAdapterOutbox.java

License:Open Source License

@Override
public void start() {

    log.info("Twitter adapter outbox '" + actor + "' starting...");

    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setUseSSL(true).setOAuthConsumerKey(consumerKey)
            .setOAuthConsumerSecret(consumerSecret).setOAuthAccessToken(twitterAccessToken)
            .setOAuthAccessTokenSecret(twitterAccessTokenSecret);

    TwitterFactory tf = new TwitterFactory(cb.build());
    twitter = tf.getInstance();//from ww  w  .  j av a 2  s. c om

    log.info("Twitter adapter outbox '" + actor + "' started.");
}

From source file:org.jraf.irondad.handler.twitter.follow.TwitterFollowHandler.java

License:Open Source License

private static Twitter getTwitter(HandlerContext handlerContext) {
    Twitter res = (Twitter) handlerContext.get("twitter");
    if (res == null) {
        TwitterFollowHandlerConfig twitterFollowHandlerConfig = (TwitterFollowHandlerConfig) handlerContext
                .getHandlerConfig();/*from  w ww.  ja  va2s.c om*/
        ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
        configurationBuilder.setDebugEnabled(true)
                .setOAuthConsumerKey(twitterFollowHandlerConfig.getOauthConsumerKey());
        configurationBuilder.setOAuthConsumerSecret(twitterFollowHandlerConfig.getOauthConsumerSecret());
        configurationBuilder.setOAuthAccessToken(twitterFollowHandlerConfig.getOauthAccessToken());
        configurationBuilder.setOAuthAccessTokenSecret(twitterFollowHandlerConfig.getOauthAccessTokenSecret());
        TwitterFactory twitterFactory = new TwitterFactory(configurationBuilder.build());
        res = twitterFactory.getInstance();

        handlerContext.put("twitter", res);
    }
    return res;
}

From source file:org.jraf.irondad.handler.twitter.links.TwitterLinksHandler.java

License:Open Source License

private static Twitter getTwitter(HandlerContext handlerContext) {
    Twitter res = (Twitter) handlerContext.get("twitter");
    if (res == null) {
        TwitterLinksHandlerConfig twitterLinksHandlerConfig = (TwitterLinksHandlerConfig) handlerContext
                .getHandlerConfig();/*from   w w w  .  j  a  va2 s . c o  m*/
        ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
        configurationBuilder.setDebugEnabled(true)
                .setOAuthConsumerKey(twitterLinksHandlerConfig.getOauthConsumerKey());
        configurationBuilder.setOAuthConsumerSecret(twitterLinksHandlerConfig.getOauthConsumerSecret());
        configurationBuilder.setOAuthAccessToken(twitterLinksHandlerConfig.getOauthAccessToken());
        configurationBuilder.setOAuthAccessTokenSecret(twitterLinksHandlerConfig.getOauthAccessTokenSecret());
        TwitterFactory twitterFactory = new TwitterFactory(configurationBuilder.build());
        res = twitterFactory.getInstance();

        handlerContext.put("twitter", res);
    }
    return res;
}