我有一个从 facebook api 检索所有朋友的代码,但我只想获取使用应用程序的 facebook 朋友。我试过 fb.request("me/friends?fields=installed"); 但从未工作过我需要额外的许可吗?
这是我的代码:
jsonUser = fb.request("me/friends");
friendObj = Util.parseJson(jsonUser);
friendArray = friendObj.getJSONArray("data");
friendlist = new ArrayList<String[][]>();
String[][] friendsToList = new String[1][2];
int friendCount = 0;
String fId, fNm;
JSONObject friend;
for (int i = 0;i<friendArray.length();i++){
//Get a JSONObject from the JSONArray
friend = friendArray.getJSONObject(i);
//Extract the strings from the JSONObject
friendsToList[0][0] = friend.getString("id");
friendsToList[0][1] = friend.getString("name");
friendlist.add(friendsToList);
//Set the values to our arrays
Log.e("Tester",""+ friendsToList[0][0]+" "+ friendsToList[0][1]);
friendCount ++;
}