public void uploadPic(String message, String getImgUrl) throws Exception { try { System.out.println(" ON UPLOAD PIC FUNCTION getImgUrl "+getImgUrl); // URL url = new URL("http://faveplatewebservice.siplstudio.com/uploads/big_dish/oooo14n7464rO4_thumb.png"); URL url = new URL(getImgUrl); URLConnection urlConnection = url.openConnection(); InputStream in = new BufferedInputStream(urlConnection.getInputStream()); StatusUpdate status = new StatusUpdate("Check Out FavPlates on appstore, which offers you to add and find exciting dishes near you. "+message); //status.setMedia(file); status.setMedia("Check Out FavPlates on appstore, which offers you to add and find exciting dishes near you. "+message, in); mTwitter.updateStatus(status); } catch (TwitterException e) { Log.d("TAG", "Pic Upload error" + e.getExceptionCode()); throw e; } }
@Override public String toString() { return getMessage() + (nested ? "" : "\nRelevant discussions can be found on the Internet at:\n" + "\thttp://www.google.co.jp/search?q=" + getExceptionDiagnosis().getStackLineHashAsHex() + " or\n\thttp://www.google.co.jp/search?q=" + getExceptionDiagnosis().getLineNumberHashAsHex()) + "\nTwitterException{" + (nested ? "" : "exceptionCode=[" + getExceptionCode() + "], ") + "statusCode=" + statusCode + ", message=" + errorMessage + ", code=" + errorCode + ", retryAfter=" + getRetryAfter() + ", rateLimitStatus=" + getRateLimitStatus() + ", version=" + Version.getVersion() + '}'; }
private void verifyCredentials(ResultBuilder builder, Map<String, Object> parameters) throws Exception { try { TwitterConfiguration configuration = setProperties(new TwitterConfiguration(), parameters); Twitter twitter = configuration.getTwitter(); twitter.verifyCredentials(); } catch (TwitterException e) { // verifyCredentials throws TwitterException when Twitter service or // network is unavailable or if supplied credential is wrong ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getErrorMessage()) .detail("twitter_error_code", e.getErrorCode()) .detail("twitter_status_code", e.getStatusCode()) .detail("twitter_exception_code", e.getExceptionCode()) .detail("twitter_exception_message", e.getMessage()) .detail("twitter_exception_caused-by-network-issue", e.isCausedByNetworkIssue()) .detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName()) .detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e); // For a complete list of error codes see: // https://dev.twitter.com/overview/api/response-codes if (e.getErrorCode() == 89) { errorBuilder.parameterKey("accessToken"); } builder.error(errorBuilder.build()); } } }