如何检索 Facebook 好友列表并将其保存以进行解析? [英] How to retrieve Facebook friendlist and save it to parse?

查看:30
本文介绍了如何检索 Facebook 好友列表并将其保存以进行解析?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个利用用户 Facebook 好友列表的应用程序.我的解析后端有一个名为 fbFriendsList 的数组类型列.环顾四周后,到目前为止我有这个:

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);
                    }
                }];

但我还是没有得到朋友.稍后在一个函数中,我将数组保存到 PFUser 像这样

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];

但这会返回 Found: 0.为什么这些方法不检索好友列表?我该如何做并将其保存到我的解析后端?

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?

推荐答案

自 2014 年 4 月起,您只会获得那些也授权您的应用程序的用户,请查看更改日志:https://developers.facebook.com/docs/apps/changelog

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.

现在获得所有朋友的唯一方法是使用 invitable_friends 用于邀请用户使用您的应用程序和 taggable_friends 用于标记用户.但在你的情况下,没有办法获得所有这些.

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.

这篇关于如何检索 Facebook 好友列表并将其保存以进行解析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆