List of usage examples for org.apache.http.impl.client BasicResponseHandler BasicResponseHandler
BasicResponseHandler
From source file:com.escabe.TraktApi.java
private static Object getDataFromJSON(String url, boolean login, String type) { url = baseurl + url;/*from w w w. j a v a 2 s. c o m*/ url = url.replaceAll("%k", apikey); url = url.replaceAll("%u", username); HttpClient httpclient = new DefaultHttpClient(); if (login) { HttpPost httppost = new HttpPost(url); JSONObject jsonpost = new JSONObject(); try { jsonpost.put("username", username); jsonpost.put("password", password); httppost.setEntity(new StringEntity(jsonpost.toString())); String response = httpclient.execute(httppost, new BasicResponseHandler()); if (type == "array") { return new JSONArray(response); } else { return new JSONObject(response); } } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { // No login HttpGet httpget = new HttpGet(url); try { String response = httpclient.execute(httpget, new BasicResponseHandler()); if (type == "array") { return new JSONArray(response); } else { return new JSONObject(response); } } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }
From source file:net.wasdev.gameon.concierge.PlayerClient.java
/** * Obtain apiKey for player id.//from w w w . j av a2s . c o m * * @param playerId * The player id * @return The apiKey for the player */ public String getApiKey(String playerId) throws IOException { String jwt = getClientJwtForId(playerId); HttpClient client = null; if ("development".equals(System.getenv("CONCIERGE_PLAYER_MODE"))) { System.out.println("Using development mode player connection. (DefaultSSL,NoHostNameValidation)"); try { HttpClientBuilder b = HttpClientBuilder.create(); //use the default ssl context, we have a trust store configured for player cert. SSLContext sslContext = SSLContext.getDefault(); //use a very trusting truststore.. (not needed..) //SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(); b.setSSLContext(sslContext); //disable hostname validation, because we'll need to access the cert via a different hostname. b.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE); client = b.build(); } catch (Exception e) { throw new IOException(e); } } else { client = HttpClientBuilder.create().build(); } HttpGet hg = new HttpGet(playerLocation + "/" + playerId + "?jwt=" + jwt); System.out.println("Building web target " + hg.getURI().toString()); try { // Make GET request using the specified target, get result as a // string containing JSON HttpResponse r = client.execute(hg); String result = new BasicResponseHandler().handleResponse(r); // Parse the JSON response, and retrieve the apiKey field value. ObjectMapper om = new ObjectMapper(); JsonNode jn = om.readValue(result, JsonNode.class); return jn.get("apiKey").textValue(); } catch (HttpResponseException hre) { System.out.println( "Error communicating with player service: " + hre.getStatusCode() + " " + hre.getMessage()); throw hre; } catch (ResponseProcessingException rpe) { System.out.println("Error processing response " + rpe.getResponse().toString()); throw new IOException(rpe); } catch (ProcessingException | WebApplicationException ex) { //bad stuff. System.out.println("Hmm.. " + ex.getMessage()); throw new IOException(ex); } catch (IOException io) { System.out.println("Utoh.. " + io.getMessage()); throw new IOException(io); } }
From source file:org.nasa.openspace.gc.geolocation.LocationActivity.java
public void executeMultipartPost() throws Exception { try {// w ww .jav a 2 s. com HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://192.168.14.102/index.php/photos/upload"); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); Session.image.compress(Bitmap.CompressFormat.PNG, 100, byteStream); byte[] buffer = byteStream.toByteArray(); ByteArrayBody body = new ByteArrayBody(buffer, "profile_image"); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); entity.addPart("gambar", body); entity.addPart("nama", new StringBody(Session.name)); //POST nama entity.addPart("keterangan", new StringBody(Session.caption)); //POST keterangan entity.addPart("lat", new StringBody(lat)); //POST keterangan entity.addPart("lon", new StringBody(longt)); //POST keterangan post.setEntity(entity); System.out.println("post entity length " + entity.getContentLength()); ResponseHandler handler = new BasicResponseHandler(); String response = client.execute(post, handler); } catch (Exception e) { Log.e(e.getClass().getName(), e.getMessage()); } }
From source file:org.sakaiproject.hybrid.util.NakamuraAuthenticationHelper.java
/** * Calls Nakamura to determine the identity of the current user. * // w ww . j a v a 2s . c o m * @param request * @return null if user cannot be authenticated. * @throws IllegalArgumentException * @throws IllegalStateException * For all unexpected cause Exceptions. */ public AuthInfo getPrincipalLoggedIntoNakamura(final HttpServletRequest request) { LOG.debug("getPrincipalLoggedIntoNakamura(HttpServletRequest request)"); if (request == null) { throw new IllegalArgumentException("HttpServletRequest == null"); } final Object cache = threadLocalManager.get(THREAD_LOCAL_CACHE_KEY); if (cache instanceof AuthInfo) { LOG.debug("cache hit!"); return (AuthInfo) cache; } @SuppressWarnings("PMD.DataflowAnomalyAnalysis") AuthInfo authInfo = null; final String secret = getSecret(request); if (secret != null) { final HttpClient httpClient = httpClientProvider.getHttpClient(); try { final URI uri = new URI(validateUrl + secret); final HttpGet httpget = new HttpGet(uri); // authenticate to Nakamura using x-sakai-token mechanism final String token = xSakaiToken.createToken(hostname, principal); httpget.addHeader(XSakaiToken.X_SAKAI_TOKEN_HEADER, token); // final ResponseHandler<String> responseHandler = new BasicResponseHandler(); final String responseBody = httpClient.execute(httpget, responseHandler); authInfo = new AuthInfo(responseBody); } catch (HttpResponseException e) { // usually a 404 error - could not find cookie / not valid if (LOG.isDebugEnabled()) { LOG.debug("HttpResponseException: " + e.getMessage() + ": " + e.getStatusCode() + ": " + validateUrl + secret); } } catch (Exception e) { LOG.error(e.getMessage(), e); throw new IllegalStateException(e); } finally { httpClient.getConnectionManager().shutdown(); } } // cache results in thread local threadLocalManager.set(THREAD_LOCAL_CACHE_KEY, authInfo); return authInfo; }
From source file:org.graphwalker.restful.RestTest.java
private String getResonseBody() { try {//from ww w. j av a 2 s . c o m return new BasicResponseHandler().handleResponse(response); } catch (IOException e) { Assert.fail(e.getMessage()); } return null; }
From source file:com.nexmo.sns.sdk.NexmoSnsClient.java
public SnsServiceResult submit(final Request request) throws Exception { log.info("NEXMO-REST-SNS-SERVICE-CLIENT ... submit request [ " + request.toString() + " ] "); // Construct a query string as a list of NameValuePairs List<NameValuePair> params = new ArrayList<>(); params.add(new BasicNameValuePair("api_key", this.apiKey)); params.add(new BasicNameValuePair("api_secret", this.apiSecret)); params.add(new BasicNameValuePair("cmd", request.getCommand())); if (request.getQueryParameters() != null) for (Map.Entry<String, String> entry : request.getQueryParameters().entrySet()) params.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); //String baseUrl = https ? this.baseUrlHttps : this.baseUrlHttp; // Now that we have generated a query string, we can instanciate a HttpClient, // construct a POST or GET method and execute to submit the request String response = null;// www . j av a 2 s. c om HttpPost method = new HttpPost(this.baseUrl); method.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); String url = this.baseUrl + "?" + URLEncodedUtils.format(params, "utf-8"); try { if (this.httpClient == null) this.httpClient = HttpClientUtils.getInstance(this.connectionTimeout, this.soTimeout) .getNewHttpClient(); HttpResponse httpResponse = this.httpClient.execute(method); int status = httpResponse.getStatusLine().getStatusCode(); if (status != 200) throw new Exception( "got a non-200 response [ " + status + " ] from Nexmo-HTTPS for url [ " + url + " ] "); response = new BasicResponseHandler().handleResponse(httpResponse); log.info(".. SUBMITTED NEXMO-HTTP URL [ " + url + " ] -- response [ " + response + " ] "); } catch (Exception e) { log.info("communication failure: " + e); method.abort(); return new SnsServiceResult(request.getCommand(), SnsServiceResult.STATUS_COMMS_FAILURE, "Failed to communicate with NEXMO-HTTP url [ " + url + " ] ..." + e, null, null); } // parse the response doc ... /* We receive a response from the api that looks like this, parse the document and turn it into an instance of SnsServiceResult <nexmo-sns> <command>subscribe|publish</command> <resultCode>0</resultCode> <resultMessage>OK!</resultMessage> <transactionId>${transaction-id}</transactionId> <subscriberArn>${subscriber}</subscriberArn> </nexmo-sns> */ Document doc = null; synchronized (this.documentBuilder) { try { doc = this.documentBuilder.parse(new InputSource(new StringReader(response))); } catch (Exception e) { throw new Exception("Failed to build a DOM doc for the xml document [ " + response + " ] ", e); } } String command = null; int resultCode = -1; String resultMessage = null; String transactionId = null; String subscriberArn = null; NodeList replies = doc.getElementsByTagName("nexmo-sns"); for (int i = 0; i < replies.getLength(); i++) { Node reply = replies.item(i); NodeList nodes = reply.getChildNodes(); for (int i2 = 0; i2 < nodes.getLength(); i2++) { Node node = nodes.item(i2); if (node.getNodeType() != Node.ELEMENT_NODE) continue; if (node.getNodeName().equals("command")) { command = node.getFirstChild() == null ? null : node.getFirstChild().getNodeValue(); } else if (node.getNodeName().equals("resultCode")) { String str = node.getFirstChild() == null ? null : node.getFirstChild().getNodeValue(); try { resultCode = Integer.parseInt(str); } catch (Exception e) { log.error("xml parser .. invalid value in <resultCode> node [ " + str + " ] "); resultCode = SnsServiceResult.STATUS_INTERNAL_ERROR; } } else if (node.getNodeName().equals("resultMessage")) { resultMessage = node.getFirstChild() == null ? null : node.getFirstChild().getNodeValue(); } else if (node.getNodeName().equals("transactionId")) { transactionId = node.getFirstChild() == null ? null : node.getFirstChild().getNodeValue(); } else if (node.getNodeName().equals("subscriberArn")) { subscriberArn = node.getFirstChild() == null ? null : node.getFirstChild().getNodeValue(); } else log.error("xml parser .. unknown node found in nexmo-sns [ " + node.getNodeName() + " ] "); } } if (resultCode == -1) throw new Exception("Xml Parser - did not find a <resultCode> node"); return new SnsServiceResult(command, resultCode, resultMessage, transactionId, subscriberArn); }
From source file:org.apache.ofbiz.passport.event.GitHubEvents.java
/** * Parse GitHub login response and login the user if possible. * //from w w w . j a va2s . com * @return */ public static String parseGitHubResponse(HttpServletRequest request, HttpServletResponse response) { String authorizationCode = request.getParameter(PassportUtil.COMMON_CODE); String state = request.getParameter(PassportUtil.COMMON_STATE); if (!state.equals(request.getSession().getAttribute(SESSION_GITHUB_STATE))) { String errMsg = UtilProperties.getMessage(resource, "GitHubFailedToMatchState", UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } if (UtilValidate.isEmpty(authorizationCode)) { String error = request.getParameter(PassportUtil.COMMON_ERROR); String errorDescpriton = request.getParameter(PassportUtil.COMMON_ERROR_DESCRIPTION); String errMsg = null; try { errMsg = UtilProperties.getMessage(resource, "FailedToGetGitHubAuthorizationCode", UtilMisc.toMap(PassportUtil.COMMON_ERROR, error, PassportUtil.COMMON_ERROR_DESCRIPTION, URLDecoder.decode(errorDescpriton, "UTF-8")), UtilHttp.getLocale(request)); } catch (UnsupportedEncodingException e) { errMsg = UtilProperties.getMessage(resource, "GetGitHubAuthorizationCodeError", UtilHttp.getLocale(request)); } request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } Debug.logInfo("GitHub authorization code: " + authorizationCode, module); GenericValue oauth2GitHub = getOAuth2GitHubConfig(request); if (UtilValidate.isEmpty(oauth2GitHub)) { String errMsg = UtilProperties.getMessage(resource, "GetOAuth2GitHubConfigError", UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } String clientId = oauth2GitHub.getString(PassportUtil.COMMON_CLIENT_ID); String secret = oauth2GitHub.getString(PassportUtil.COMMON_CLIENT_SECRET); String returnURI = oauth2GitHub.getString(PassportUtil.COMMON_RETURN_RUL); // Grant token from authorization code and oauth2 token // Use the authorization code to obtain an access token String accessToken = null; String tokenType = null; try { URI uri = new URIBuilder().setScheme(TokenEndpoint.substring(0, TokenEndpoint.indexOf(":"))) .setHost(TokenEndpoint.substring(TokenEndpoint.indexOf(":") + 3)).setPath(TokenServiceUri) .setParameter("client_id", clientId).setParameter("client_secret", secret) .setParameter("code", authorizationCode).setParameter("redirect_uri", returnURI).build(); HttpPost postMethod = new HttpPost(uri); CloseableHttpClient jsonClient = HttpClients.custom().build(); // Debug.logInfo("GitHub get access token query string: " + postMethod.getURI(), module); postMethod.setConfig(PassportUtil.StandardRequestConfig); postMethod.setHeader(PassportUtil.ACCEPT_HEADER, "application/json"); CloseableHttpResponse postResponse = jsonClient.execute(postMethod); String responseString = new BasicResponseHandler().handleResponse(postResponse); // Debug.logInfo("GitHub get access token response code: " + postResponse.getStatusLine().getStatusCode(), module); // Debug.logInfo("GitHub get access token response content: " + responseString, module); if (postResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { Debug.logInfo("Json Response from GitHub: " + responseString, module); JSON jsonObject = JSON.from(responseString); JSONToMap jsonMap = new JSONToMap(); Map<String, Object> userMap = jsonMap.convert(jsonObject); accessToken = (String) userMap.get("access_token"); tokenType = (String) userMap.get("token_type"); // Debug.logInfo("Generated Access Token : " + accessToken, module); // Debug.logInfo("Token Type: " + tokenType, module); } else { String errMsg = UtilProperties.getMessage(resource, "GetOAuth2GitHubAccessTokenError", UtilMisc.toMap("error", responseString), UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } } catch (UnsupportedEncodingException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } catch (IOException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } catch (ConversionException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } catch (URISyntaxException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } // Get User Profile HttpGet getMethod = new HttpGet(ApiEndpoint + UserApiUri); Map<String, Object> userInfo = null; try { userInfo = GitHubAuthenticator.getUserInfo(getMethod, accessToken, tokenType, UtilHttp.getLocale(request)); } catch (AuthenticatorException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } finally { getMethod.releaseConnection(); } // Debug.logInfo("GitHub User Info:" + userInfo, module); // Store the user info and check login the user return checkLoginGitHubUser(request, userInfo, accessToken); }
From source file:fr.lissi.belilif.om2m.rest.WebServiceActions.java
/** * Do delete.// w ww. j av a2 s . c om * * @param uri the uri * @param headers the headers * @return the http get simple resp * @throws ClientProtocolException the client protocol exception * @throws IOException Signals that an I/O exception has occurred. * @throws HttpResponseException the http response exception */ public static HttpGetSimpleResp doDelete(String uri, HashMap<String, String> headers) throws ClientProtocolException, IOException, HttpResponseException { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpGetSimpleResp resp = new HttpGetSimpleResp(); try { HttpDelete httpDelete = new HttpDelete(uri); for (String key : headers.keySet()) { httpDelete.addHeader(key, headers.get(key)); } CloseableHttpResponse response = httpclient.execute(httpDelete); resp.setStatusCode(response.getStatusLine().getStatusCode()); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT) { try { HttpEntity entity = response.getEntity(); if (entity != null) { // TODO to use for performance in the future resp.setResult(new BasicResponseHandler().handleResponse(response)); } EntityUtils.consume(entity); } finally { response.close(); } } else { // TODO optimiz (repeating code) throw new HttpResponseException(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase()); } } finally { httpclient.close(); } return resp; }
From source file:org.apache.ofbiz.passport.event.LinkedInEvents.java
/** * Parse LinkedIn login response and login the user if possible. * /*from ww w. j a v a2 s .co m*/ * @return */ public static String parseLinkedInResponse(HttpServletRequest request, HttpServletResponse response) { String authorizationCode = request.getParameter(PassportUtil.COMMON_CODE); String state = request.getParameter(PassportUtil.COMMON_STATE); if (!state.equals(request.getSession().getAttribute(SESSION_LINKEDIN_STATE))) { String errMsg = UtilProperties.getMessage(resource, "LinkedInFailedToMatchState", UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } if (UtilValidate.isEmpty(authorizationCode)) { String error = request.getParameter(PassportUtil.COMMON_ERROR); String errorDescpriton = request.getParameter(PassportUtil.COMMON_ERROR_DESCRIPTION); String errMsg = null; try { errMsg = UtilProperties.getMessage(resource, "FailedToGetLinkedInAuthorizationCode", UtilMisc.toMap(PassportUtil.COMMON_ERROR, error, PassportUtil.COMMON_ERROR_DESCRIPTION, URLDecoder.decode(errorDescpriton, "UTF-8")), UtilHttp.getLocale(request)); } catch (UnsupportedEncodingException e) { errMsg = UtilProperties.getMessage(resource, "GetLinkedInAuthorizationCodeError", UtilHttp.getLocale(request)); } request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } // Debug.logInfo("LinkedIn authorization code: " + authorizationCode, module); GenericValue oauth2LinkedIn = getOAuth2LinkedInConfig(request); if (UtilValidate.isEmpty(oauth2LinkedIn)) { String errMsg = UtilProperties.getMessage(resource, "GetOAuth2LinkedInConfigError", UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } String clientId = oauth2LinkedIn.getString(PassportUtil.ApiKeyLabel); String secret = oauth2LinkedIn.getString(PassportUtil.SecretKeyLabel); String returnURI = oauth2LinkedIn.getString(envPrefix + PassportUtil.ReturnUrlLabel); // Grant token from authorization code and oauth2 token // Use the authorization code to obtain an access token String accessToken = null; try { URI uri = new URIBuilder().setScheme(TokenEndpoint.substring(0, TokenEndpoint.indexOf(":"))) .setHost(TokenEndpoint.substring(TokenEndpoint.indexOf(":") + 3)).setPath(TokenServiceUri) .setParameter("client_id", clientId).setParameter("client_secret", secret) .setParameter("grant_type", "authorization_code").setParameter("code", authorizationCode) .setParameter("redirect_uri", returnURI).build(); HttpPost postMethod = new HttpPost(uri); CloseableHttpClient jsonClient = HttpClients.custom().build(); // Debug.logInfo("LinkedIn get access token query string: " + postMethod.getURI(), module); postMethod.setConfig(PassportUtil.StandardRequestConfig); CloseableHttpResponse postResponse = jsonClient.execute(postMethod); String responseString = new BasicResponseHandler().handleResponse(postResponse); // Debug.logInfo("LinkedIn get access token response code: " + postResponse.getStatusLine().getStatusCode(), module); // Debug.logInfo("LinkedIn get access token response content: " + responseString, module); if (postResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { // Debug.logInfo("Json Response from LinkedIn: " + responseString, module); JSON jsonObject = JSON.from(responseString); JSONToMap jsonMap = new JSONToMap(); Map<String, Object> userMap = jsonMap.convert(jsonObject); accessToken = (String) userMap.get("access_token"); // Debug.logInfo("Generated Access Token : " + accessToken, module); } else { String errMsg = UtilProperties.getMessage(resource, "GetOAuth2LinkedInAccessTokenError", UtilMisc.toMap("error", responseString), UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } } catch (UnsupportedEncodingException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } catch (IOException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } catch (ConversionException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } catch (URISyntaxException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } // Get User Profile HttpGet getMethod = new HttpGet(TokenEndpoint + UserApiUri + "?oauth2_access_token=" + accessToken); Document userInfo = null; try { userInfo = LinkedInAuthenticator.getUserInfo(getMethod, UtilHttp.getLocale(request)); } catch (IOException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } catch (AuthenticatorException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } catch (SAXException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } catch (ParserConfigurationException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } finally { getMethod.releaseConnection(); } // Debug.logInfo("LinkedIn User Info:" + userInfo, module); // Store the user info and check login the user return checkLoginLinkedInUser(request, userInfo, accessToken); }
From source file:com.concentricsky.android.khanacademy.data.remote.VideoProgressPostTask.java
private VideoProgressResult remoteFetch(VideoProgressUpdate update) { VideoProgressResult result = null;/*from w ww .j a va2s. c om*/ String q = String.format(Locale.US, "last_second_watched=%d&seconds_watched=%d", update.getLast_second_watched(), update.getSeconds_watched()); url = String.format("%s?%s", url, q); Log.d(KAAPIAdapter.LOG_TAG, "posting video progress: " + url); // Use this! The response is chunked, so don't try to get the Content-Length and read a buffer of that length. // However, the response is small, so it isn't a big deal that this handler blocks until it's done. ResponseHandler<String> h = new BasicResponseHandler(); HttpClient httpClient = new DefaultHttpClient(); HttpPost request = new HttpPost(url); ObjectMapper mapper = new ObjectMapper(); try { consumer.sign(request); String response = httpClient.execute(request, h); result = mapper.readValue(response, VideoProgressResult.class); // DEBUG // User ud = result.action_results.user_data; // UserVideo uv = result.action_results.user_video; // if (result.action_results.badges_earned != null) { // List<Badge> badges = result.action_results.badges_earned.getBadges(); // if (badges != null) { // Log.d(KAAPIAdapter.LOG_TAG, "Badges: "); // for (Badge b : badges) { // Log.d(KAAPIAdapter.LOG_TAG, " " + b.getDescription() + " (" + b.getPoints() + " points)"); // } // } else { // Log.d(KAAPIAdapter.LOG_TAG, "badges was null"); // } // } else { // Log.d(KAAPIAdapter.LOG_TAG, "badges was null"); // } // // Log.d(KAAPIAdapter.LOG_TAG, "url was " + url); // Log.d(KAAPIAdapter.LOG_TAG, "got data for " + ud.getNickname() + ", video points: " + uv.getPoints()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (OAuthMessageSignerException e) { e.printStackTrace(); } catch (OAuthExpectationFailedException e) { e.printStackTrace(); } catch (OAuthCommunicationException e) { e.printStackTrace(); } catch (HttpResponseException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return result; }