如果用户在他们的联系人中有该信息,那么他们也是该人在 Facebook 上的朋友。只需使用图形 api 并获取朋友列表并使用选择的联系人姓名过滤他们,或者让用户从由 facebook api 查询的返回名称组成的列表视图中进行选择。
try {
JSONObject response = Util.parseJson(facebook.request(
"/me/friends", new Bundle(), "GET"));
JSONArray jArray = response.getJSONArray("data");
for (int i = 0; i < jArray.length(); i++) {
JSONObject json_data = jArray.getJSONObject(i);
tempMap = new HashMap<String, Object>();
tempMap.put("friend", json_data.getString("name"));
tempMap.put("id", json_data.getString("id"));
friendlist.add(tempMap);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (FacebookError e) {
e.printStackTrace();
}