List of usage examples for twitter4j TwitterException getMessage
@Override
public String getMessage()
From source file:org.btcwolf.twitter.TwitterAgent.java
License:Open Source License
public void publish(String message) { try {//from w w w .j a v a 2s . com LOGGER.debug("publishing twitter status " + message); twitter.getInstance().updateStatus(message); } catch (TwitterException e) { LOGGER.error("could not publish status " + e.getMessage()); } catch (IllegalStateException e) { LOGGER.error("could not publish status " + e.getMessage()); } }
From source file:org.celstec.arlearn2.oauth.OauthTwitterWorker.java
License:Open Source License
public String afterSuccesfullAuthentication(HttpServletRequest request) { Twitter twitter = new TwitterFactory().getInstance(); RequestToken token = (RequestToken) request.getSession().getAttribute("requestToken"); String verifier = request.getParameter("oauth_verifier"); twitter.setOAuthConsumer(client_id, client_secret); try {/*from w w w . j av a 2s.c o m*/ AccessToken accessToken = twitter.getOAuthAccessToken(token, verifier); User user = twitter.verifyCredentials(); AccountJDO account = AccountManager.addAccount("" + user.getId(), AccountJDO.TWITTERCLIENT, "", "", "", user.getName(), user.getProfileImageURL(), false); UserLoggedInManager.submitOauthUser(account.getUniqueId(), accessToken.getToken()); return accessToken.getToken(); } catch (TwitterException e) { log.log(Level.SEVERE, e.getMessage(), e); } return null; }
From source file:org.examproject.tweet.service.SimpleTweetService.java
License:Apache License
private Status updateStatus(String content) { Status status = null;// w w w.j a v a 2s .c o m try { Twitter twitter = getTwitter(); status = twitter.updateStatus(content); } catch (TwitterException te) { LOG.error("an error occurred: " + te.getMessage()); throw new RuntimeException(te); } return status; }
From source file:org.examproject.tweet.service.SimpleTweetService.java
License:Apache License
private Status destroyStatus(long statusId) { Status status = null;//w w w . j a v a2 s .c o m try { Twitter twitter = getTwitter(); status = twitter.destroyStatus(statusId); } catch (TwitterException te) { LOG.error("an error occurred: " + te.getMessage()); throw new RuntimeException(te); } return status; }
From source file:org.examproject.tweet.service.SimpleTweetService.java
License:Apache License
private Status replyStatus(String content, long statusId) { Status status = null;/*from www . jav a 2 s. c o m*/ StatusUpdate statusUpdate = new StatusUpdate(content); statusUpdate.setInReplyToStatusId(statusId); try { Twitter twitter = getTwitter(); status = twitter.updateStatus(statusUpdate); } catch (TwitterException te) { LOG.error("an error occurred: " + te.getMessage()); throw new RuntimeException(te); } return status; }
From source file:org.examproject.tweet.service.SimpleTweetService.java
License:Apache License
private Status createOrDeleteFavorite(long statusId) { Status status = null;//w w w. j av a 2s . c om try { Twitter twitter = getTwitter(); status = twitter.createFavorite(statusId); return status; } catch (TwitterException te) { // if the message included 'You have already favorited this status'. String message = te.getMessage(); // TODO: what is good in this? if (message.indexOf("You have already favorited this status") != -1) { try { Twitter twitter = getTwitter(); status = twitter.destroyFavorite(statusId); return status; } catch (TwitterException te1) { LOG.error("an error occurred: " + te1.getMessage()); throw new RuntimeException(te1); } } LOG.error("an error occurred: " + te.getMessage()); throw new RuntimeException(te); } }
From source file:org.examproject.tweet.service.SimpleTweetService.java
License:Apache License
private Status retweetStatus(long statusId) { Status status = null;/* ww w .jav a 2 s. com*/ try { Twitter twitter = getTwitter(); status = twitter.retweetStatus(statusId); } catch (TwitterException te) { LOG.error("an error occurred: " + te.getMessage()); throw new RuntimeException(te); } return status; }
From source file:org.gatein.security.oauth.portlet.twitter.TwitterPortletRequest.java
License:Apache License
private String getErrorMessage(TwitterException te) { String errorMessage = "Twitter error occured. StatusCode: " + te.getStatusCode() + ", Details: " + te.getMessage(); if (te.getCause() != null) { errorMessage = errorMessage + ", Cause: " + te.getCause(); }/*from w ww . j a v a 2 s.co m*/ return errorMessage; }
From source file:org.gatein.security.oauth.twitter.TwitterProcessorImpl.java
License:Open Source License
@Override public TwitterAccessTokenContext validateTokenAndUpdateScopes(TwitterAccessTokenContext accessToken) throws OAuthException { try {/* w ww . j a v a 2s . c o m*/ // Perform validation by obtaining some info about user Twitter twitter = getAuthorizedTwitterInstance(accessToken); twitter.verifyCredentials(); return accessToken; } catch (TwitterException tw) { if (tw.getStatusCode() == 401) { throw new OAuthException(OAuthExceptionCode.ACCESS_TOKEN_ERROR, "Error when verifying twitter access token: " + tw.getMessage(), tw); } else { throw new OAuthException(OAuthExceptionCode.IO_ERROR, "IO Error when obtaining tokenInfo: " + tw.getClass() + ": " + tw.getMessage(), tw); } } }
From source file:org.junjun.twitter.GetUserTimeline.java
License:Apache License
/** * Usage: java twitter4j.examples.timeline.GetUserTimeline * * @param args String[]/*from w w w . j av a 2s .c om*/ */ public static void main(String[] args) { // gets Twitter instance with default credentials Twitter twitter = new TwitterFactory().getInstance(); try { List<Status> statuses; String user; Paging paging = new Paging(1); paging.setCount(100); if (args.length == 1) { user = args[0]; /* statuses = twitter.getUserTimeline(Long.parseLong(user),paging);*/ statuses = twitter.getUserTimeline(Long.parseLong(user)); } else { user = twitter.verifyCredentials().getScreenName(); statuses = twitter.getUserTimeline(); } System.out.println("Showing @" + user + "'s user timeline."); int i = 0; for (Status status : statuses) { System.out.println(i++ + "@" + status.getUser().getName() + " - " + status + " "); } System.out.println(); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get timeline: " + te.getMessage()); System.exit(-1); } }