Vote count:
0
I am trying to make an Instagram API Call to retrieve all images with the #selfie. I can't seem to see the response from the server though.
What should I be doing so that I can see the JSON Response, and also create an object to grab each image URL etc.
public static class FetchTaggedImages extends AsyncTask<String, Void, Void> {
private static final String API_URL = "http://ift.tt/1ve8JiX";
@Override
protected Void doInBackground(String... params) {
String mAccessToken = params[0];
Log.e("DID IT MAKE IT?", "IT MADE IT");
try {
URL url = new URL(API_URL + "?access_token=" + mAccessToken);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.connect();
String response = streamToString(urlConnection.getInputStream());
System.out.println(response);
Log.e("RESPONSE", response);
//JSONObject jsonObj = (JSONObject) new JSONTokener(response).nextValue();
// String name = jsonObj.getJSONObject("data").getString("full_name");
// String bio = jsonObj.getJSONObject("data").getString("bio");
// Log.i(TAG, "Got name: " + name + ", bio [" + bio + "]");
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
Log.e("ONPOSTEXECUTE", "ONPOSTEXECUTE");
}
}
asked 25 secs ago
Issue creating JSONObject with Instagram API response
Aucun commentaire:
Enregistrer un commentaire