Example usage for twitter4j.auth OAuth2Token getTokenType

List of usage examples for twitter4j.auth OAuth2Token getTokenType

Introduction

In this page you can find the example usage for twitter4j.auth OAuth2Token getTokenType.

Prototype

public String getTokenType() 

Source Link

Usage

From source file:Beans.Crawler.java

/**
 * Get a fully application-authenticated Twitter object useful for making subsequent calls.
 *
 * @return   Twitter4J Twitter object that's ready for API calls
 *//*from w w  w .  ja v a2  s.c  om*/
public static 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());

    //   And create the Twitter object!
    return new TwitterFactory(cb.build()).getInstance();

}

From source file:br.com.controller.TweetController.java

public static Twitter getTwitter() {
    OAuth2Token token;

    token = getOAuth2Token();/*from w  w  w .  j  av  a  2s  .co m*/
    ConfigurationBuilder cb = new ConfigurationBuilder();

    cb.setApplicationOnlyAuthEnabled(true);

    cb.setOAuthConsumerKey(CONSUMER_KEY);
    cb.setOAuthConsumerSecret(CONSUMER_SECRET);

    cb.setOAuth2TokenType(token.getTokenType());
    cb.setOAuth2AccessToken(token.getAccessToken());

    return new TwitterFactory(cb.build()).getInstance();
}

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  v a  2  s  . co  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:ontoSentiment.Util.java

public static Twitter getTwitter() {
    OAuth2Token token;
    token = getOAuth2Token();/*from w ww .jav  a 2  s  .  co  m*/
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setApplicationOnlyAuthEnabled(true);
    cb.setOAuthConsumerKey(CONSUMER_KEY);
    cb.setOAuthConsumerSecret(CONSUMER_SECRET);
    cb.setOAuth2TokenType(token.getTokenType());
    cb.setOAuth2AccessToken(token.getAccessToken());
    return new TwitterFactory(cb.build()).getInstance();
}

From source file:org.apache.blur.demo.twitter.Whiteboard.java

License:Apache License

/**
 * @param args//from   w  w w  .  j ava  2s  . c  o  m
 * @throws TwitterException
 */
public static void main(String[] args) throws TwitterException {
    Twitter twitter = new TwitterFactory(new ConfigurationBuilder().build()).getInstance();
    OAuth2Token token = twitter.getOAuth2Token();
    System.out.println(token.getTokenType());

    try {
        Query query = new Query("Apache");
        QueryResult result;
        do {
            result = twitter.search(query);
            List<Status> tweets = result.getTweets();
            for (Status tweet : tweets) {
                System.out.println("@" + tweet.getUser().getScreenName() + " - " + tweet.getText());

            }
        } while ((query = result.nextQuery()) != null);
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to search tweets: " + te.getMessage());
        System.exit(-1);
    }

}

From source file:tweetdownloader.cnr_stable.version.TwitterAuthHandler.java

/**
 * This method give you the auth to work with Twitter API
 * @return istance of Twitter/*  w w  w. j  a va  2s  . co m*/
 */
public Twitter getTwitter() {
    OAuth2Token token;
    token = getOAuth2Token();
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setApplicationOnlyAuthEnabled(true);
    cb.setOAuthConsumerKey(CONSUMER_KEY);
    cb.setOAuthConsumerSecret(CONSUMER_SECRET);
    cb.setOAuth2TokenType(token.getTokenType());
    cb.setOAuth2AccessToken(token.getAccessToken());
    return new TwitterFactory(cb.build()).getInstance();
}