List of usage examples for twitter4j TwitterFactory TwitterFactory
public TwitterFactory()
From source file:net.firejack.platform.web.security.twitter.BaseTwitterAuthenticationProcessor.java
License:Apache License
protected Twitter populateTwitterService() { if (!isEnable()) throw new IllegalStateException("Service disabled."); Twitter twitter = new TwitterFactory().getInstance(); twitter.setOAuthConsumer(getTwitterConsumerKey(), getTwitterConsumerSecret()); return twitter; }
From source file:net.lacolaco.smileessence.twitter.OAuthSession.java
License:Open Source License
public String getAuthorizationURL() { Twitter twitter = new TwitterFactory().getInstance(); RequestTokenTask task = new RequestTokenTask(twitter); task.execute();//w w w . ja v a 2s . co m try { requestToken = task.get(); return requestToken.getAuthorizationURL(); } catch (Exception e) { e.printStackTrace(); Logger.error(e.getMessage()); return null; } }
From source file:net.lacolaco.smileessence.twitter.OAuthSession.java
License:Open Source License
public AccessToken getAccessToken(String pinCode) { Twitter twitter = new TwitterFactory().getInstance(); AccessTokenTask task = new AccessTokenTask(twitter, requestToken, pinCode); task.execute();/*from ww w . j av a2s . c om*/ try { return task.get(); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); Logger.error(e.toString()); return null; } }
From source file:net.lacolaco.smileessence.twitter.TwitterApi.java
License:Open Source License
public Twitter getTwitter() { Twitter twitter = new TwitterFactory().getInstance(); twitter.setOAuthAccessToken(new AccessToken(token, tokenSecret)); return twitter; }
From source file:net.nitram509.twitter.TwitterClientToolbox.java
License:Open Source License
public Twitter getTwitterFor(AccessToken accessToken) { return new TwitterFactory().getInstance(accessToken); }
From source file:net.nitram509.twitter.TwitterClientToolbox.java
License:Open Source License
public Twitter getTwitterAsTweetGatewayApp() { return new TwitterFactory().getInstance(); }
From source file:net.nokok.twitduke.core.twitter.StatusParser.java
License:Open Source License
/** * ???StatusParser????/*w ww.j ava 2s . c o m*/ * * @param accessToken */ public StatusParser(AccessToken accessToken) { this.twitter = new TwitterFactory().getInstance(accessToken); }
From source file:net.smileengine.tweettest.Main.java
public static void main(String[] args) throws TwitterException { Twitter twitter = new TwitterFactory().getInstance(); Status status = twitter.updateStatus("Jenkins"); }
From source file:net.tiger.star.nsen.action.IndexAction.java
License:Apache License
@Execute(validator = false, redirect = true) public String login() { Twitter twitter = new TwitterFactory().getInstance(); // RequestToken?Twitter?? try {// www .j a va 2s. c o m userDataDto.requestToken = twitter.getOAuthRequestToken(); } catch (TwitterException e) { return null; } return userDataDto.requestToken.getAuthorizationURL(); }
From source file:nl.b3p.viewer.stripes.TwitterActionBean.java
License:Open Source License
public Resolution create() throws JSONException { JSONObject json = new JSONObject(); json.put("success", Boolean.FALSE); String error = null;// ww w.ja v a2s .co m try { // The factory instance is re-useable and thread safe. Twitter twitter = new TwitterFactory().getInstance(); Query query = new Query(term); if (latestId != null) { Long longVal = Long.valueOf(latestId); query.setSinceId(longVal); } QueryResult result = twitter.search(query); JSONArray tweets = new JSONArray(); for (Status tweet : result.getTweets()) { //System.out.println(tweet.getFromUser() + ":" + tweet.getText()); JSONObject t = new JSONObject(); t.put("id_str", String.valueOf(tweet.getId())); t.put("text", tweet.getText()); t.put("user_from", tweet.getUser().getScreenName()); t.put("img_url", tweet.getUser().getProfileImageURL()); JSONObject geo = new JSONObject(); if (tweet.getGeoLocation() != null) { geo.put("lat", tweet.getGeoLocation().getLatitude()); geo.put("lon", tweet.getGeoLocation().getLongitude()); } t.put("geo", geo); tweets.put(t); } json.put("tweets", tweets); if (tweets.length() > 0) { json.put("maxId", String.valueOf(result.getMaxId())); } else { json.put("maxId", String.valueOf(latestId)); } json.put("success", Boolean.TRUE); } catch (Exception e) { error = e.toString(); if (e.getCause() != null) { error += "; cause: " + e.getCause().toString(); } } if (error != null) { json.put("error", error); } return new StreamingResolution("application/json", new StringReader(json.toString())); }