i'm create some code to get friends list using graph api but didn't find friends list.i just got total number of friends only.
Code:-
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile", "user_friends", "email"));
LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.e("Success1", "Success" + loginResult.getAccessToken().getToken());
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject json, GraphResponse response) {
progressDialog.dismiss();
if (response.getError() != null) {
// handle error
Log.e("getError", "getError");
} else {
Log.e("Success2", "Success");
try {
String jsonresult = String.valueOf(json);
Log.e("JSON", "" + jsonresult);
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/" + json.getString("id") + "/friends",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.e("response", "" + response);
}
}
).executeAsync();
} catch (JSONException e) {
e.printStackTrace();
Log.e("JSONException", "" + e.getMessage());
}
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id, first_name, last_name, email,gender, birthday, location,friends"); // Parámetros que pedimos a facebook
request.setParameters(parameters);
request.executeAsync();
}
@Override
public void onCancel() {
Log.e("cancel", "On cancel");
progressDialog.dismiss();
}
@Override
public void onError(FacebookException error) {
Log.e("Error", error.toString());
progressDialog.dismiss();
}
});
OutPut:-
{"data":[],"summary":{"total_count":475}}, error: null}