List of usage examples for twitter4j AsyncTwitter setOAuthAccessToken
void setOAuthAccessToken(AccessToken accessToken);
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; }