Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting Location of friends from facebook
    text
    copied!<p>I am trying to get home town location and current location of all my friends by my application. I came to know that for getting location I have to set permissions and write FQL. I wrote that and the URL became as <a href="https://developers.facebook.com/tools/explorer?fql=SELECT%20name,%20uid,%20current_location,%20hometown_location%20FROM%20user%20WHERE%20uid%20in%20%28SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20=%20me%28%29%29" rel="nofollow">My Graph API format</a><br> but when I use this link to get json I am not getting the values. I tried replacing %20 by space and tried that even but that too dint worked. Please tell me what went wrong. and tell me what URL should I use. </p> <p>My code to get json values..:</p> <pre><code>String q = "https://developers.facebook.com/tools/explorer?fql=SELECT name, uid, current_location, hometown_location FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me())"; HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(q); try { HttpEntity httpEntity = httpClient.execute(httpGet).getEntity(); if (httpEntity != null){ InputStream inputStream = httpEntity.getContent(); Reader in = new InputStreamReader(inputStream); BufferedReader bufferedreader = new BufferedReader(in); StringBuilder stringBuilder = new StringBuilder(); String stringReadLine = null; while ((stringReadLine = bufferedreader.readLine()) != null) { stringBuilder.append(stringReadLine + "\n"); } qResult = stringBuilder.toString(); inputStream.close(); } } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { Log.e("in try block", "in try block"); JSONObject JsonObject = new JSONObject(qResult); JSONArray JsonArray = JsonObject.getJSONArray("data"); for(int i = 0;i &lt; JsonArray.length(); i++){ Log.e("jksdhkvjsdlvm", "inside 1st for loop"); JSONObject fbInfo = JsonArray.getJSONObject(i); name = fbInfo.getString("name"); uid = fbInfo.getString("uid"); current_location = JsonObject.getJSONArray("current_location"); for(int j = 0;j &lt; current_location.length(); j++){ JSONObject currentInfo = current_location.getJSONObject(j); c_city = currentInfo.getString("city"); c_state = currentInfo.getString("state"); c_country = currentInfo.getString("country"); Log.e("---&gt;&gt;&gt;&gt;", c_city); } hometown_location = JsonObject.getJSONArray("hometown_location"); for(int k = 0;k &lt; hometown_location.length(); k++){ JSONObject homeInfo = hometown_location.getJSONObject(k); h_city = homeInfo.getString("city"); h_state = homeInfo.getString("state"); h_country = homeInfo.getString("country"); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload