Reputation: 489
I am creating an app with facebook login, and I am now able to successfully log in the user to facebook via the facebook api!
However, I am also trying to gather some information on the user, namely the number of existing friends that they have.
Note that I am NOT looking for the full list of friends (I don't know if there is an odd permission thing there or not) BUT instead I am looking only for the number of friends that the user has.
I have coded the below, but I cannot verify if it works or not because I cannot actually access the variable that I create in the request call outside of the request call. I'm guessing that there is probably a simpler (and more accurate) way to accomplish obtaining the number of friends that the user has...
Any ideas on how to accomplish this?
new Request(
Session.getActiveSession(),
"/me/friends",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
// handle the result
final int iFacebookFollowerCount = (Integer) response.getGraphObject().getProperty("total_count");
}
}
);
Upvotes: 2
Views: 895
Reputation: 3356
authButton.setReadPermissions(Arrays.asList("user_friends");
authbutton is fb login button..
You need to get permission like this.
you can check if the permission is granted by checking on the following id with your access token. If the permission is granted you can get the total count
https://graph.facebook.com/me?fields=friends{friends}&access_token=
Upvotes: 4