Example usage for twitter4j AsyncTwitter setOAuthAccessToken

List of usage examples for twitter4j AsyncTwitter setOAuthAccessToken

Introduction

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

Prototype

void setOAuthAccessToken(AccessToken accessToken);

Source Link

Document

Sets the access token

Usage

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

License:Apache License

public List<Status> asyncSearch(String query) {

    TwitterListener listener = new TwitterAdapter() {
        @Override//ww  w  . j a va  2s  . c  o  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;
}