I'm developing my first Android App using Parse and Facebook, so I'm pretty new to it.
I'm trying to retrieve the User's Friend List with Request.newMyFriendsRequest()
but it gives me an empty list when testing with real users.
As far as I know, with Graph API v2.0
this request only will return the set of the person's friends who also use the app.
For that purpose I created a fake Fb profile, I became friend with him in Facebook with my real profile, installed my app, registered with ParseUser
and Linked with Facebook using ParseFacebookUtils.link
with both profiles, but the Request returns an empty list of friends.
I've created several Test Users in Facebook's App dashboard, and simulated several friendships between them. I made the same process in my app (register with parseUser
, link with ParseFacebookUtils.link
) with two of them, and the list users.size()
returns 2 friends as expected.
Why it doesn't work with my actual profile and the fake one (which is like any other real one)??
This is how I'm linking profiles:
List<String> permissions = new ArrayList<String>();
permissions.add("public_profile");
permissions.add("user_friends");
ParseFacebookUtils.link(currentUser, permissions, MainActivity.this, new SaveCallback() {
@Override
public void done(ParseException ex) {
if (ParseFacebookUtils.isLinked(currentUser)) {
Log.d(TAG, "Woohoo, user logged in with Facebook!");
Toast.makeText(getApplicationContext(), "Facebook succesfully linked", Toast.LENGTH_LONG).show();
}
if (ex != null) {
Log.d (TAG, ex.getLocalizedMessage() + "\n + Exception Code: " + ex.getCode());
}
});
And this how I Request friends:
Request.newMyFriendsRequest(ParseFacebookUtils.getSession(), new GraphUserListCallback() {
@Override
public void onCompleted(List<GraphUser> users, Response response) {
Log.d(TAG, "Request Completed!! " + response.toString() + "----" + users.size());
if (users != null) {
List<String> friendsList = new ArrayList<String>();
for (GraphUser user : users) {
friendsList.add(user.getId());
}
}
}
}).executeAsync();.
But I can't figure out how to get the friends list of a real user. With my profile it should return 1 friend who is also registered using the app being developed...
I got an empty array because of the following:
- This will only return any friends who have used (via Facebook Login) the app making the request.
Please note!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With