title: How to get Instagram data from a user on Android?
body: <p>I'm trying to fetch user data from Instagram in a Android application, because I need to get user photos and show in a gallery, but I'm having a problem to fetch user data.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>private void fetchUserName() {
      mProgress.setMessage("Finalizing ...");
  
      new Thread() {
          @Override
          public void run() {
              Log.i(TAG, "Fetching user info");
              int what = WHAT_FINALIZE;
              try {
                  URL url = new URL(API_URL + "/users/" + mSession.getId() + "/media/recent/?access_token=" + mAccessToken);
  
                  Log.d(TAG, "Opening URL " + url.toString());
                  HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
                  urlConnection.setRequestMethod("GET");
                  urlConnection.setDoInput(true);
                  urlConnection.setDoOutput(true);
                  urlConnection.connect();
                  String response = streamToString(urlConnection.getInputStream());
                  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) {
                  what = WHAT_ERROR;
                  ex.printStackTrace();
              }
  
              mHandler.sendMessage(mHandler.obtainMessage(what, 2, 0));
          }
      }.start();  
  
  }
  </code></pre>
  
  <p>But in this part is going to catch.</p>
  
  <pre><code> String response = streamToString(urlConnection.getInputStream());
  </code></pre>
  
  <p>And I tried many ways to do JSON parse, but always give error when try to connect to url, like it:</p>
  
  <pre><code>HttpResponse httpResponse = httpClient.execute(httpPost);
  </code></pre>
  
  <p>The url logged is :</p>
  
  <p><a href="https://api.instagram.com/v1/users/699022341/?access_token=699022341.aef690f.1888e66fed5d4764aeae1c121faa14fb" rel="noreferrer">https://api.instagram.com/v1/users/699022341/?access_token=699022341.aef690f.1888e66fed5d4764aeae1c121faa14fb</a></p>
  
  <p>And the error is:</p>
  
  <pre><code>11-29 14:31:45.300: W/System.err(11916): java.io.FileNotFoundException: https://api.instagram.com/v1/users/699022341/?access_token=699022341.aef690f.1888e66fed5d4764aeae1c121faa14fb
  11-29 14:31:45.300: W/System.err(11916):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:186)
  11-29 14:31:45.300: W/System.err(11916):    at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:246)
  </code></pre>
  
  <p>I'm doing something wrong or need a Instagram permission, or something like that?</p>