신청서로 모든 내 친구들의 집 위치 및 현재 위치를 찾으려고합니다. 나는 위치를 얻으려면 권한을 설정하고 FQL을 작성해야한다는 것을 알게되었습니다. 나는 그것을 썼고 URL은 My Graph API format
이되었지만 나는이 링크를 사용하여 json을 얻었을 때 나는 값을 얻지 못했다. 나는 % 20을 공백으로 바꾸려고 시도했지만 그걸 시도해 보았다. 무엇이 잘못되었는지 말해주세요. 어떤 URL을 사용해야하는지 알려주세요. 페이스 북에서 친구 위치 얻기
내 코드
는 JSON 값을 얻을 수 있습니다 .. :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 < 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 < 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("--->>>>", c_city);
}
hometown_location = JsonObject.getJSONArray("hometown_location");
for(int k = 0;k < 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();
}
인코딩 문자열의 location_tagged 항목을 반환이
를 호출하고 사용 그리고 수동으로 공간을 대신 % 20을 넣지 마십시오. – user
URL은 이미 인코딩 된 형식입니다. 그러나 정보를 얻을 수 없습니다 .. 인코딩 된 형식과 URL 형식의 디코딩 된 형식을 모두 사용하여 시도했습니다. – Vaibs
@Vaibs : Can 실행 코드를 게시하십시오. 이 FQL 쿼리? –