Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. HttpClient httpclient = new DefaultHttpClient();
  2. // Prepare a request object
  3. HttpGet httpget = new HttpGet(args[0]);
  4. httpget.addHeader("Authorization", "Bearer " + BearerToken);
  5.  
  6. // Execute the request
  7. HttpResponse response;
  8.  
  9. JSONArray arr = new JSONArray();
  10. try {
  11. response = httpclient.execute(httpget);
  12.  
  13. HttpEntity entity = response.getEntity();
  14.  
  15. if (entity != null && response.getStatusLine().getStatusCode() == 200) {
  16. // A Simple JSON Response Read
  17. InputStream instream = entity.getContent();
  18. String result = convertStreamToString(instream);
  19. arr=new JSONArray(result);
  20. instream.close();
  21.  
  22. }
  23. } catch (ClientProtocolException e) {
  24. // TODO Auto-generated catch block
  25. Log.e("EXCEPTION",e.toString());
  26. } catch (IOException e) {
  27. // TODO Auto-generated catch block
  28. Log.e("EXCEPTION",e.toString());
  29. } catch (JSONException e) {
  30. // TODO Auto-generated catch block
  31. Log.e("EXCEPTION",e.toString());
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement