title: Android - retrieving json via HTTPS
body: <p>I've a problem with parsing json from facebook graph api.<br>
  When I'm using facebook URL:<br><code>https://graph.facebook.com/interstacjapl/feed?access_token=MyTOKEN</code> to grab json it's no working, but when I copied that json (it works in browser) and paste to my webiste <code>http://mywebsite/fb.json</code> and change site URL in the code, it works good.
  <br>When I'm using fb graph URL it shows error: </p>
  
  <pre><code>W/System.err(5534): org.json.JSONException: No value for data
  </code></pre>
  
  <p>Is this problem with parsing from https or URL or code?<br>
  <br><strong>JSONParser.java</strong><br></p>
  
  <pre><code>public class JSONParser {
  
      static InputStream is = null;
      static JSONObject jObj = null;
      static String json = "";
  
      // constructor
      public JSONParser() {
  
      }
  
      public JSONObject getJSONFromUrl(String url) {
  
          // Making HTTP request
          try {
              // defaultHttpClient
              DefaultHttpClient httpClient = new DefaultHttpClient();
              HttpPost httpPost = new HttpPost(url);
  
              HttpResponse httpResponse = httpClient.execute(httpPost);
              HttpEntity httpEntity = httpResponse.getEntity();
              is = httpEntity.getContent();           
  
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          } catch (ClientProtocolException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          try {
              BufferedReader reader = new BufferedReader(new InputStreamReader(
                      is, "iso-8859-1"), 8);
              StringBuilder sb = new StringBuilder();
              String line = null;
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
              is.close();
              json = sb.toString();
          } catch (Exception e) {
              Log.e("Buffer Error", "Error converting result " + e.toString());
          }
  
          // try parse the string to a JSON object
          try {
              jObj = new JSONObject(json);
          } catch (JSONException e) {
              Log.e("JSON Parser", "Error parsing data " + e.toString());
          }
  
          // return JSON String
          return jObj;
  
      }
  }
  </code></pre>
  
  <p><strong>MainActivity</strong><br></p>
  
  <pre><code>public class MainActivity extends Activity {
      ListView list;
      TextView ver;
      TextView name;
      TextView api;
      Button Btngetdata;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; oslist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      //URL to get JSON Array
      private static String url = "https://graph.facebook.com/interstacjapl/feed?access_token=CAACEdEose0cBANLR...";
  
      //JSON Node Names 
      private static final String TAG = "data";
      private static final String TAG_ID = "id";
      private static final String TAG_NAME = "message";
      private static final String TAG_API = "type";
  
      JSONArray android = null;
  
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_main);
          oslist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
  
  
          Btngetdata = (Button)findViewById(R.id.getdata);
          Btngetdata.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View view) {
                   new JSONParse().execute();
  
  
              }
          });
  
  
      }
  
  
  
      private class JSONParse extends AsyncTask&lt;String, String, JSONObject&gt; {
           private ProgressDialog pDialog;
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
               ver = (TextView)findViewById(R.id.vers);
               name = (TextView)findViewById(R.id.name);
               api = (TextView)findViewById(R.id.api);
              pDialog = new ProgressDialog(MainActivity.this);
              pDialog.setMessage("Getting Data ...");
              pDialog.setIndeterminate(false);
              pDialog.setCancelable(true);
              pDialog.show();
  
  
  
          }
  
          @Override
          protected JSONObject doInBackground(String... args) {
  
              JSONParser jParser = new JSONParser();
  
              // Getting JSON from URL
              JSONObject json = jParser.getJSONFromUrl(url);
              return json;
          }
           @Override
           protected void onPostExecute(JSONObject json) {
               pDialog.dismiss();
               try {
                      // Getting JSON Array from URL
                      android = json.getJSONArray(TAG);
                      for(int i = 0; i &lt; android.length(); i++){
                      JSONObject c = android.getJSONObject(i);
  
                      // Storing  JSON item in a Variable
                      String ver = c.getString(TAG_ID);
                      String name = c.getString(TAG_NAME);
                      String api = c.getString(TAG_API);
  
  
  
  
                      // Adding value HashMap key =&gt; value
  
  
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                      map.put(TAG_ID, ver);
                      map.put(TAG_NAME, name);
                      map.put(TAG_API, api);
  
                      oslist.add(map);
                      list=(ListView)findViewById(R.id.list);
  
  
  
  
  
                      ListAdapter adapter = new SimpleAdapter(MainActivity.this, oslist,
                              R.layout.list_v,
                              new String[] { TAG_ID,TAG_NAME, TAG_API }, new int[] {
                                      R.id.vers,R.id.name, R.id.api});
  
                      list.setAdapter(adapter);
                      list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
                          @Override
                          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                                                  int position, long id) {
                              Toast.makeText(MainActivity.this, "You Clicked at "+oslist.get(+position).get("name"), Toast.LENGTH_SHORT).show();
  
                          }
                      });
  
                      }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  
  
           }
      }
  
  }
  </code></pre>