List of usage examples for twitter4j TwitterException getMessage
@Override
public String getMessage()
From source file:org.yamaLab.TwitterConnector.GetAccessToken.java
License:Apache License
/** * Usage: java twitter4j.examples.oauth.GetAccessToken [consumer key] [consumer secret] * * @param args message *///from ww w. j a va 2s . c o m public static void main(String[] args) { File file = new File("TweetByWikiEx2.properties"); Properties prop = new Properties(); InputStream is = null; OutputStream os = null; try { /* try-0 */ if (file.exists()) { is = new FileInputStream(file); prop.load(is); } if (args.length < 2) { if (null == prop.getProperty("oauth.consumerKey") && null == prop.getProperty("oauth.consumerSecret")) { // consumer key/secret are not set in twitter4j.properties System.out.println( "Usage: java twitter4j.examples.oauth.GetAccessToken [consumer key] [consumer secret]"); System.exit(-1); } } else { prop.setProperty("oauth.consumerKey", args[0]); prop.setProperty("oauth.consumerSecret", args[1]); os = new FileOutputStream("twitter4j.properties"); prop.store(os, "twitter4j.properties"); } } catch (IOException ioe) { /* try-0 */ ioe.printStackTrace(); System.exit(-1); } finally { /* try-0 */ if (is != null) { try { is.close(); } catch (IOException ignore) { } } if (os != null) { try { os.close(); } catch (IOException ignore) { } } try { /* try-1 in try-0 */ Twitter twitter = new TwitterFactory().getInstance(); RequestToken requestToken = twitter.getOAuthRequestToken(); System.out.println("Got request token."); System.out.println("Request token: " + requestToken.getToken()); System.out.println("Request token secret: " + requestToken.getTokenSecret()); AccessToken accessToken = null; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (null == accessToken) { /* while */ System.out.println("Open the following URL and grant access to your account:"); System.out.println(requestToken.getAuthorizationURL()); try { /* try-1 */ Desktop.getDesktop().browse(new URI(requestToken.getAuthorizationURL())); } catch (UnsupportedOperationException ignore) { } catch (IOException ignore) { } catch (URISyntaxException e) { throw new AssertionError(e); } /* try-1 */ System.out.print("Enter the PIN(if available) and hit enter after you granted access.[PIN]:"); String pin = br.readLine(); try { /* try-3 in try-0 */ if (pin.length() > 0) { accessToken = twitter.getOAuthAccessToken(requestToken, pin); } else { accessToken = twitter.getOAuthAccessToken(requestToken); } } catch (TwitterException te) { if (401 == te.getStatusCode()) { System.out.println("Unable to get the access token."); } else { te.printStackTrace(); } } /* try-3 in try-0 */ } /* while */ System.out.println("Got access token."); System.out.println("Access token: " + accessToken.getToken()); System.out.println("Access token secret: " + accessToken.getTokenSecret()); try { /* try-2 in try 0 */ prop.setProperty("oauth.accessToken", accessToken.getToken()); prop.setProperty("oauth.accessTokenSecret", accessToken.getTokenSecret()); os = new FileOutputStream(file); prop.store(os, "twitter4j.properties"); os.close(); } catch (IOException ioe) { ioe.printStackTrace(); System.exit(-1); } finally { if (os != null) { try { os.close(); } catch (IOException ignore) { } } } System.out.println("Successfully stored access token to " + file.getAbsolutePath() + "."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get accessToken: " + te.getMessage()); System.exit(-1); } catch (IOException ioe) { ioe.printStackTrace(); System.out.println("Failed to read the system input."); System.exit(-1); } /* try-1 in try-0 */ } /* try-0 */ }
From source file:org.yawlfoundation.yawl.twitterService.TwitterService.java
License:Open Source License
private String updateStatus(String msg) { String result;/*from w w w.ja va 2s. c o m*/ Twitter twitter = new TwitterFactory().getInstance(); try { twitter.updateStatus(msg); result = "Status successfully posted to Twitter"; } catch (TwitterException te) { result = te.getMessage(); } return result; }
From source file:Origin.Timeline.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true);//from w w w.java 2 s. c om cb.setOAuthConsumerKey(CONSUMER_KEY); cb.setOAuthConsumerSecret(CONSUMER_SECRET); cb.setOAuthAccessToken(ACCESS_TOKEN); cb.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET); try { Twitter twitter = new TwitterFactory(cb.build()).getInstance(); User user = twitter.verifyCredentials(); Paging paging = new Paging(1, 200); ResponseList<Status> userstatus = twitter.getHomeTimeline(paging); request.setAttribute("userstatus", userstatus); request.getRequestDispatcher("/timeline.jsp").forward(request, response); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get timeline: " + te.getMessage()); System.exit(-1); } }
From source file:peoplesearch.FindFriendsAndFollowers.java
public void GetFollowersIDs() { try {/*from www . ja v a 2 s . co m*/ // I need to pass the Person name and the TwitterID. //String targetname="Philip Bergkvist"; Twitter twitter = new TwitterFactory().getInstance(); long cursor = -1; IDs ids; ResponseList<User> users1 = null; ResponseList<User> users2 = null; System.out.println("Listing followers's ids."); GraphManager mgr = EmbeddedGraphManager.getInstance(); mgr.init(new File("/usr/local/Cellar/neo4j/2.1.7/libexec/data/forlang1.db")); //mgr.addTwitterAccount(new TwitterAccountImpl(new Date(), "I am Studying", 13, 82, true,"Aalborg", "Philiptwoshoes", 2730631792L)); List<TwitterAccount> twitteraccountslist; twitteraccountslist = null; twitteraccountslist = mgr.listTwitterAccounts(); System.out.println("the number of twitter account in the neo4J DB is" + twitteraccountslist.size()); for (TwitterAccount Twit : twitteraccountslist) { do { TwitterLimitWait tlw = new TwitterLimitWait(); tlw.CheckLimit(); if (0 < twitteraccountslist.size()) { ids = twitter.getFollowersIDs(Twit.getScreenName(), cursor); //.getFollowersIDs(pep[0], cursor); //ids = twitter.getFollowersIDs("Philiptwoshoes", cursor); //.getFollowersIDs(pep[0], cursor); tlw.CheckLimit(); users1 = twitter.getFollowersList(Twit.getScreenName(), cursor); tlw.CheckLimit(); users2 = twitter.getFriendsList(Twit.getScreenName(), cursor); } else { tlw.CheckLimit(); ids = twitter.getFollowersIDs(cursor); } for (User user : users1) { tlw.CheckLimit(); System.out.println("the follower called " + user.getName() + " with twitter handler " + user.getScreenName()); String username = user.getName(); //mgr.addPerson(new PersonImpl(username)); Date Creation = user.getCreatedAt(); tlw.CheckLimit(); String descript = user.getDescription(); boolean empty1 = user.getDescription().isEmpty(); if (empty1 == true) { descript = " "; } tlw.CheckLimit(); int followers = user.getFollowersCount(); tlw.CheckLimit(); int following = user.getFriendsCount(); boolean geo = user.isGeoEnabled(); String loc = user.getLocation(); boolean empty2 = user.getLocation().isEmpty(); if (empty2 == true) { loc = " "; } String screenname = user.getScreenName(); boolean empty3 = user.getScreenName().isEmpty(); if (empty3 == true) { screenname = " "; } tlw.CheckLimit(); long twitID = user.getId(); mgr.linkPersonToTwitterAccount(new PersonImpl(username), new TwitterAccountImpl(Creation, descript, followers, following, geo, loc, screenname, twitID)); mgr.linkTwitterAccounts(new TwitterAccountImpl(Creation, descript, followers, following, geo, loc, screenname, twitID), Twit); } System.out.println("The total number of followers is: " + users1.size()); // the same procedure for the Following for (User user : users2) { tlw.CheckLimit(); System.out.println("the following called " + user.getName() + " with twitter handler " + user.getScreenName()); String username1 = user.getName(); //mgr.addPerson(new PersonImpl(username1)); Date Creation = user.getCreatedAt(); String descript = user.getDescription(); boolean empty1 = user.getDescription().isEmpty(); if (empty1 == true) { descript = " "; } int followers = user.getFollowersCount(); int following = user.getFriendsCount(); boolean geo = user.isGeoEnabled(); String loc = user.getLocation(); boolean empty2 = user.getLocation().isEmpty(); if (empty2 == true) { loc = " "; } String screenname = user.getScreenName(); tlw.CheckLimit(); boolean empty3 = user.getScreenName().isEmpty(); if (empty3 == true) { screenname = " "; } tlw.CheckLimit(); long twitID = user.getId(); //mgr.addTwitterAccount(new TwitterAccountImpl(Creation,descript,followers,following,geo,loc,screenname,twitID)); mgr.linkPersonToTwitterAccount(new PersonImpl(username1), new TwitterAccountImpl(Creation, descript, followers, following, geo, loc, screenname, twitID)); mgr.linkTwitterAccounts(Twit, new TwitterAccountImpl(Creation, descript, followers, following, geo, loc, screenname, twitID)); } System.out.println("The total number of friend is: " + users2.size()); //} } while ((cursor = ids.getNextCursor()) != 0); } mgr.destroy(); // I have to check that the second iteration works fine, because i could not test that. System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get followers' ids: " + te.getMessage()); System.exit(-1); } }
From source file:profiles.FilesThreaderParser.java
License:Apache License
public static void main(String[] args) throws ClassNotFoundException, SQLException, JSONException, FileNotFoundException, UnsupportedEncodingException { // Check how many arguments were passed in if ((args == null) || (args.length < 5)) { System.err.println("5 Parameters are required to launch a Job."); System.err.println("First: String 'INPUT: /input/path/'"); System.err.println("Second: String 'OUTPUT: /output/path/'"); System.err.println("Third: (int) Total Number Of Jobs"); System.err.println("Fourth: (int) This Job Number"); System.err.println("Fifth: (int) Number of seconds to pause"); System.err.println("Example: fileToRun /input/path/ /output/path/ " + "10 1 3"); System.exit(-1);//ww w. j a v a 2 s. com } // TODO documentation for command line AppOAuth AppOAuths = new AppOAuth(); Misc helpers = new Misc(); String endpoint = "/users/lookup"; String inputPath = null; try { inputPath = StringEscapeUtils.escapeJava(args[0]); } catch (Exception e) { System.err.println("Argument " + args[0] + " must be an String."); System.exit(-1); } String outputPath = null; try { outputPath = StringEscapeUtils.escapeJava(args[1]); } catch (Exception e) { System.err.println("Argument " + args[1] + " must be an String."); System.exit(-1); } int TOTAL_JOBS = 0; try { TOTAL_JOBS = Integer.parseInt(args[2]); } catch (NumberFormatException e) { System.err.println("Argument " + args[2] + " must be an integer."); System.exit(1); } int JOB_NO = 0; try { JOB_NO = Integer.parseInt(args[3]); } catch (NumberFormatException e) { System.err.println("Argument " + args[3] + " must be an integer."); System.exit(1); } int secondsToPause = 0; try { secondsToPause = Integer.parseInt(args[4]); } catch (NumberFormatException e) { System.err.println("Argument" + args[4] + " must be an integer."); System.exit(-1); } try { int TotalWorkLoad = 0; ArrayList<String> allFiles = null; try { final File folder = new File(inputPath); allFiles = helpers.listFilesForSingleFolder(folder); TotalWorkLoad = allFiles.size(); } catch (Exception e) { System.err.println("Input folder is not exists: " + e.getMessage()); System.exit(-1); } System.out.println("Total Workload is: " + TotalWorkLoad); if (TotalWorkLoad < 1) { System.err.println("No targeted user file exists in: " + inputPath); System.exit(-1); } if (TOTAL_JOBS > TotalWorkLoad) { System.err.println("Number of jobs are more than total work" + " load. Please reduce 'Number of jobs' to launch."); System.exit(-1); } float TotalWorkLoadf = TotalWorkLoad; float TOTAL_JOBSf = TOTAL_JOBS; float res = (TotalWorkLoadf / TOTAL_JOBSf); int chunkSize = (int) Math.ceil(res); int offSet = JOB_NO * chunkSize; int chunkSizeToGet = (JOB_NO + 1) * chunkSize; System.out.println("My Share is " + chunkSize); System.out.println("My offSet is " + offSet); System.out.println("My chunkSizeToGet is " + chunkSizeToGet); System.out.println(); // Load OAuh User TwitterFactory tf = AppOAuths.loadOAuthUser(endpoint, TOTAL_JOBS, JOB_NO); Twitter twitter = tf.getInstance(); int RemainingCalls = AppOAuths.RemainingCalls; int RemainingCallsCounter = 0; System.out.println("First Time OAuth Remianing Calls: " + RemainingCalls); String Screen_name = AppOAuths.screen_name; System.out.println("First Time Loaded OAuth Screen_name: " + Screen_name); System.out.println(); System.out.println("Going to get Profiles."); if (JOB_NO + 1 == TOTAL_JOBS) { chunkSizeToGet = TotalWorkLoad; } secondsToPause = (TOTAL_JOBS * secondsToPause) - (JOB_NO * secondsToPause); System.out.println("secondsToPause: " + secondsToPause); helpers.pause(secondsToPause); // to write output in a file System.out.flush(); List<String> fileNamesShare = allFiles.subList(offSet, chunkSizeToGet); for (String fileName : fileNamesShare) { System.out.println("Going to parse file: " + fileName); try { // open file to write all profiles String filesPath = outputPath + "/"; PrintWriter writer = new PrintWriter(filesPath + "/" + fileName, "UTF-8"); try (BufferedReader br = new BufferedReader(new FileReader(inputPath + "/" + fileName))) { String jsonString; while ((jsonString = br.readLine()) != null) { // process the line. List<String> fileContent = new ArrayList<>(); fileContent.add(jsonString); String[] strarray = fileContent.toArray(new String[0]); String ss = Arrays.toString(strarray); JSONArray obj = new JSONArray(ss); JSONObject obj4 = (JSONObject) obj.get(0); JSONArray idsS = (JSONArray) obj4.get("ids"); ArrayList<String> Idslist = new ArrayList<String>(); if (idsS != null) { int len = idsS.length(); for (int i = 0; i < len; i++) { Idslist.add(idsS.get(i).toString()); } } for (int start = 0; start < Idslist.size(); start += 100) { int end = Math.min(start + 100, Idslist.size()); List<String> sublist = Idslist.subList(start, end); long[] idsdata = new long[sublist.size()]; for (int i = 0; i < sublist.size(); i++) { idsdata[i] = Long.valueOf(sublist.get(i)); } ResponseList<User> profiles = null; while (true) { try { profiles = twitter.lookupUsers(idsdata); if (profiles.size() > 0) { for (User user : profiles) { String rawJSON = TwitterObjectFactory.getRawJSON(user); // put profilesJSON in a file try { writer.println(rawJSON); } catch (Exception e) { System.err.println(e.getMessage()); System.exit(0); } } break; } } catch (TwitterException te) { // If rate limit reached then switch Auth // user RemainingCallsCounter++; if (RemainingCallsCounter >= RemainingCalls) { // Load OAuth user tf = AppOAuths.loadOAuthUser(endpoint, TOTAL_JOBS, JOB_NO); twitter = tf.getInstance(); System.out.println("New User Loaded" + " OAuth Screen_name: " + AppOAuths.screen_name); RemainingCalls = AppOAuths.RemainingCalls - 2; RemainingCallsCounter = 0; System.out.println("New Remianing Calls: " + RemainingCalls); } } } // while get profiles // If rate limit reached then switch Auth user RemainingCallsCounter++; if (RemainingCallsCounter >= RemainingCalls) { // Load OAuth user tf = AppOAuths.loadOAuthUser(endpoint, TOTAL_JOBS, JOB_NO); twitter = tf.getInstance(); System.out.println( "New User Loaded OAuth " + "Screen_name: " + AppOAuths.screen_name); RemainingCalls = AppOAuths.RemainingCalls - 2; RemainingCallsCounter = 0; System.out.println("New Remianing Calls: " + RemainingCalls); } } } } writer.close(); } // read my single file catch (IOException e) { System.err.println("Failed to read lines from " + fileName); } // delete file if processed File fileToDelete = new File(inputPath + "/" + "/" + fileName); fileToDelete.delete(); // to write output in a file System.out.flush(); } // all my files // If rate limit reached then switch Auth user RemainingCallsCounter++; if (RemainingCallsCounter >= RemainingCalls) { // load auth user tf = AppOAuths.loadOAuthUser(endpoint, TOTAL_JOBS, JOB_NO); twitter = tf.getInstance(); System.out.println("New Loaded OAuth User Screen_name: " + AppOAuths.screen_name); RemainingCalls = AppOAuths.RemainingCalls; RemainingCallsCounter = 0; System.out.println("New OAuth Remianing Calls: " + RemainingCalls); } } catch (TwitterException te) { // te.printStackTrace(); System.err.println("Failed to get Profiles: " + te.getMessage()); System.exit(-1); } System.out.println("!!!! DONE !!!!"); // Close System.out for this thread which will // flush and close this thread. System.out.close(); }
From source file:rtb.RandomTweetBotTask.java
License:Apache License
@Override public void run() { try {// ww w .j a va 2s. c om bot.readJsonFile(fileName); bot.updateNextTweet(); } catch (IOException ioe) { ioe.printStackTrace(); System.exit(1); } catch (TwitterException te) { System.err.println(te.getMessage()); } }
From source file:ru.mail.sphere.java_hw5_vasilyev.twitteraccessor.Accessor.java
public static Collection<Tweet> search(String query, Date since, Date until, String lang, int querySize) { Twitter twitter = new TwitterFactory(config).getInstance(); Collection<Tweet> methodResult = new ArrayList<>(); try {/*from w w w . ja v a 2s .c o m*/ Accessor.meetRateLimits(twitter); Query queryObject = Accessor.buildSearchQuery(query, since, until, lang, querySize); QueryResult result = twitter.search(queryObject); List<Status> tweets = result.getTweets(); for (Status tweet : tweets) { methodResult.add(Accessor.buildTweetFromStatus(tweet)); } } catch (TwitterException te) { System.err.println(String.format("TwitterException occured: %s", te.getMessage())); System.err.println(Arrays.toString(te.getStackTrace())); System.err.println(Program.EXTERMINATUS); } return methodResult; }
From source file:se.aceone.housenews.UpdateStatus.java
License:Apache License
/** * Usage: java twitter4j.examples.tweets.UpdateStatus [text] * /*from www . j a v a2 s. c om*/ * @param args * message */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.tweets.UpdateStatus [text]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); // get request token. // this will throw IllegalStateException if access token is already available twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); handleAccessToken(twitter); Status status = twitter.updateStatus(args[0] + " : " + System.currentTimeMillis()); System.out.println("Successfully updated the status to [" + status.getText() + "]."); System.exit(0); } catch (IllegalStateException ie) { ie.printStackTrace(); // access token is already available, or consumer key/secret is not set. } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get timeline: " + te.getMessage()); System.exit(-1); } catch (IOException ioe) { ioe.printStackTrace(); System.out.println("Failed to read the system input."); System.exit(-1); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } }
From source file:sentinets.ImportTweets.java
License:Open Source License
private List<Status> getTweets(String queryStr, int countOfTweets) { Query query = new Query(queryStr); query.setCount(countOfTweets);/*from w w w.j av a 2 s .com*/ query.setLang("en"); QueryResult result = null; List<Status> tweets = new ArrayList<Status>(); do { try { result = twitter.search(query); } catch (TwitterException e) { e.printStackTrace(); e.printStackTrace(); System.out.println("Failed to search tweets: " + e.getMessage()); } tweets.addAll(result.getTweets()); } while ((query = result.nextQuery()) != null && tweets.size() <= countOfTweets); return tweets; }
From source file:social.controller.PostToSocial.java
@Override public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { super.processRequest(request, response); boolean face = false; boolean twit = false; try {/*from w ww . ja v a2 s . c o m*/ getSqlMethodsInstance().session = request.getSession(); Integer user_id = (Integer) getSqlMethodsInstance().session.getAttribute("UID"); String htmlString = (String) getSqlMethodsInstance().session.getAttribute("htmlString"); String isFacebook = request.getParameter("isFacebook"); String isTwitter = request.getParameter("isTwitter"); String getImageFile = request.getParameter("imageToPost"); String getFile = request.getParameter("imagePost"); String url = request.getParameter("url"); String file_image_path = AppConstants.LAYOUT_IMAGES_HOME + File.separator + getImageFile; // String file_image_path = getServletContext().getRealPath("") + "/temp/"+getImageFile; String imagePostURL = ServletUtil.getServerName(request.getServletContext()); //String imagePostURL = AppConstants.LAYOUT_IMAGES_HOME + getImageFile; if (isFacebook.equalsIgnoreCase("true")) { String accessToken = request.getParameter("accesstoken"); String posttext = request.getParameter("postText"); String title = request.getParameter("title"); String description = request.getParameter("description"); String url1 = request.getParameter("url"); facebook = new FacebookFactory().getInstance(); facebook.setOAuthAppId("592852577521569", "a87cc0c30d792fa5dd0aaef6b43994ef"); facebook.setOAuthPermissions("publish_actions, publish_pages,manage_pages"); // File file = new File(file_image_path); facebook.setOAuthAccessToken(new AccessToken(accessToken)); if (title == "") { Media media = new Media(new File(file_image_path)); PhotoUpdate update = new PhotoUpdate(media); update.message(posttext); facebook.postPhoto(update); } else { logger.info(title); PostUpdate post = new PostUpdate(posttext).picture(new URL( imagePostURL + "DownloadImage?image_type=LAYOUT_IMAGES&image_name=" + getImageFile)) .name(title).link(new URL(url1)).description(description); facebook.postFeed(post); } try { getSqlMethodsInstance().setSocialPostHistory(user_id, htmlString, false, true, getImageFile); } catch (Exception ex) { Logger.getLogger(PostToSocial.class.getName()).log(Level.SEVERE, null, ex.getCause()); Logger.getLogger(PostToSocial.class.getName()).log(Level.SEVERE, null, ex.getMessage()); } } if (isTwitter.equalsIgnoreCase("true")) { try { AccessToken accTok = null; String shortUrl = ""; ConfigurationBuilder twitterConfigBuilder = new ConfigurationBuilder(); twitterConfigBuilder.setDebugEnabled(true); twitterConfigBuilder.setOAuthConsumerKey("K7TJ3va8cyAeh6oN3Hia91S2o"); twitterConfigBuilder .setOAuthConsumerSecret("IWUt2aDVTHgUc8N0qI0cF1Z1dTAEQ7CSgnBymZNr3BPSmtkNHL"); twitterConfigBuilder.setOAuthAccessToken(request.getParameter("twittweraccestoken")); twitterConfigBuilder.setOAuthAccessTokenSecret(request.getParameter("twitterTokenSecret")); Twitter twitter = new TwitterFactory(twitterConfigBuilder.build()).getInstance(); String statusMessage = request.getParameter("text").replace("bit.ly/1XOkJo", ""); shortUrl = request.getParameter("shorturl"); if (shortUrl.length() > 0) { String StatusMessageWithoutUrl = statusMessage.substring(0, statusMessage.length()); if (StatusMessageWithoutUrl.length() + shortUrl.length() < 140) { statusMessage = StatusMessageWithoutUrl + " " + shortUrl; } else { int urlLength = shortUrl.length() + 1; int statusLength = 115 - urlLength; statusMessage = StatusMessageWithoutUrl.substring(0, statusLength); statusMessage = statusMessage + " " + shortUrl; } } File file = new File(file_image_path); int count = statusMessage.length(); StatusUpdate status = new StatusUpdate(statusMessage); // set the image to be uploaded here. status.setMedia(file); twitter.updateStatus(status); try { getSqlMethodsInstance().setSocialPostHistory(user_id, htmlString, false, true, getImageFile); } catch (Exception ex) { Logger.getLogger(PostToSocial.class.getName()).log(Level.SEVERE, null, ex.getCause()); Logger.getLogger(PostToSocial.class.getName()).log(Level.SEVERE, null, ex.getMessage()); } } catch (TwitterException te) { PrintWriter out1 = response.getWriter(); out1.println("Twitter Exception: " + te.getMessage()); Logger.getLogger(PostToSocial.class.getName()).log(Level.SEVERE, null, te.getCause()); Logger.getLogger(PostToSocial.class.getName()).log(Level.SEVERE, null, te.getMessage()); } catch (Exception e) { Logger.getLogger(PostToSocial.class.getName()).log(Level.SEVERE, null, e); Logger.getLogger(PostToSocial.class.getName()).log(Level.SEVERE, null, e.getMessage()); } } } catch (FacebookException e) { Logger.getLogger(PostToSocial.class.getName()).log(Level.SEVERE, null, e.getCause()); Logger.getLogger(PostToSocial.class.getName()).log(Level.SEVERE, null, e.getMessage()); } }