如何检索Facebook的朋友列表并保存解析? [英] How to retrieve Facebook friendlist and save it to parse?

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

问题描述

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

  //我的权限数组
NSArray * permissionsArray = @ [@ user_about_me,@email,@user_friends];
//验证用户第一次登录后,朋友的fb请求
[FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection * connection,id result,NSError * error){
if(!错误){

NSArray * friendObjects = [result objectForKey:@data];
// fbFriendIds是一个Mutable数组,我已声明
fbFriendIds = [NSMutableArray arrayWithCapacity:friendObjects.count];
//创建一个朋友的Facebook ID列表
for(NSDictionary * friendObject in friendObjects){
[fbFriendIds addObject:[friendObject objectForKey:@id]];
}

}
}];

通过这样做,我没有收到列表中的任何朋友。所以我试过这个:

  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> *朋友的朋友){
NSLog(@我有一个名为%@,id%@的朋友,friend.name,friend.id);
}
}];

但我还没有得到朋友。稍后在函数中,我将数组保存到 PFUser ,这样

 用户[@fbFriendsList] =朋友; 


[user saveInBackground];

但这返回找到:0 。为什么这些方法不能检索好友列表?如何做到这一点,并将其保存到我的解析后端?

解决方案

自2014年4月以来,应用程序也可以查看更改日志: https://developers.facebook.com/docs/apps / changelog



没有授权您的应用程序的用户无法知道您是否存储他们的数据,所以如果您考虑隐私,这是有道理的。 / p>

现在获取所有朋友的唯一方法是使用 invitable_friends ,邀请用户访问您的应用和 taggable_friends 用于标记用户。但是,在你的情况下,没有办法让所有的。


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?

解决方案

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.

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

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