Example usage for twitter4j AsyncTwitter setOAuthConsumer

List of usage examples for twitter4j AsyncTwitter setOAuthConsumer

Introduction

In this page you can find the example usage for twitter4j AsyncTwitter setOAuthConsumer.

Prototype

void setOAuthConsumer(String consumerKey, String consumerSecret);

Source Link

Document

sets the OAuth consumer key and consumer secret

Usage

From source file:org.primefaces.examples.service.TwitterAPIService.java

License:Apache License

public List<Status> asyncSearch(String query) {

    TwitterListener listener = new TwitterAdapter() {
        @Override//from w  ww . jav  a 2s  .  co  m
        public void searched(QueryResult queryResult) {
            asyncTweets = queryResult.getTweets();
        }

        @Override
        public void onException(TwitterException e, TwitterMethod method) {
            logger.severe(e.getMessage());
        }
    };

    AsyncTwitter twitter = new AsyncTwitterFactory().getInstance();
    twitter.setOAuthConsumer(twitter_consumer_key, twitter_consumer_secret);
    twitter.setOAuthAccessToken(new AccessToken(access_token, access_token_secret));
    twitter.addListener(listener);
    Query q = new Query(query);
    twitter.search(q);
    return asyncTweets;
}