Reputation: 5628
I am making an app that utilizes Facebook friendlist of the user. I have an array type column on my parse backend named fbFriendsList
. After looking around, So far I have this:
//my permission array
NSArray *permissionsArray = @[ @"user_about_me",@"email", @"user_friends"];
//My fb request for friends after verifying that user is logging in the first time
[FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSArray *friendObjects = [result objectForKey:@"data"];
//fbFriendIds is a Mutable array i have declared
fbFriendIds = [NSMutableArray arrayWithCapacity:friendObjects.count];
// Create a list of friends' Facebook IDs
for (NSDictionary *friendObject in friendObjects) {
[fbFriendIds addObject:[friendObject objectForKey:@"id"]];
}
}
}];
By doing that, I didn't receive any friends in the list. So I tried this one:
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
friends = [result objectForKey:@"data"];
NSLog(@"Found: %i friends", friends.count);
for (NSDictionary<FBGraphUser>* friend in friends) {
NSLog(@"I have a friend named %@ with id %@", friend.name, friend.id);
}
}];
But I still didn't get the friends. Later in a function I am saving the array to PFUser
like this
user[@"fbFriendsList"] = friends;
[user saveInBackground];
But this returns Found: 0
. Why aren't these methods retrieving friends list? How can I do it and save it to my parse backend?
Upvotes: 2
Views: 1489
Reputation: 74014
Since April 2014, you only get those users who authorized your App too, take a look at the changelog: https://developers.facebook.com/docs/apps/changelog
Users who did not authorized your App have no possibility to know if you store their data, so it makes sense if you think about privacy.
The only way to get all friends nowadays is to use invitable_friends for inviting users to your App and taggable_friends for tagging users. But in your case, there is no way to get all of them.
Upvotes: 3