I am able to access the id, firstname, lastname, gender, and email of a GraphUser by using the following code. But, I also need access to \"location\", \"number of frien
To get number of friends please refer to the following link:
https://developers.facebook.com/docs/graph-api/reference/v2.4/user/friends
Permissions needed would be: user_friends
, which you already have included..
You'll get friends count in field 'summary' in the name of total_count
Similar question: facebook api on android - how can I get the number of friends that a user has?
loginBtn.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
new GraphRequest(
loginResult.getAccessToken(),
"/me/friends",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.i("response", response.getJSONArray().toString()); //find the summary 'total_count' in the response
}
}
).executeAsync();
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException exception) {
}
});
This is a pretty straightforward answer and the facebook documentation covers these details. https://developers.facebook.com/docs/reference/android/current . https://developers.facebook.com/docs/graph-api
Here is the answer anyway!
You will need user_friends for the number of friends. It returns the total count of friends.
The default permission set called "basic info" has been removed, and replaced by "public profile".
user_location for location.
user_work_history for the work company.
please note : users can choose to not give these permissions to your app, in which case you should handle those scenarios properly, else your app will get rejected in the review process.