Created
January 24, 2012 23:18
-
-
Save adam-davis/1673421 to your computer and use it in GitHub Desktop.
A snippet of Java code for retrieving JSON results from PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static JSONArray HttpGetJSON(String url) throws ClientProtocolException, IOException | |
{ | |
JSONArray jsonArrayResults = null; | |
HttpClient client = new DefaultHttpClient(); | |
HttpGet loginPost = new HttpGet(url); | |
HttpResponse response=client.execute(loginPost); | |
String phpJsonResults= EntityUtils.toString(response.getEntity()); | |
try { | |
jsonArrayResults = new JSONArray(phpJsonResults); | |
} catch (JSONException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
return jsonArrayResults; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment