ios - 仅从 Facebook iOS 获取新 friend

标签 ios swift facebook facebook-ios-sdk

我们的应用程序使用 Firebase。对于应用程序中的身份验证,我们使用 Facebook。在 Facebook SDK 的帮助下,我获得了用户的好友 问题是,我只能请求“新好友”吗?比如我请求了10月25日的所有好友列表,为了下次不再请求用户的所有好友列表,我从需要用户好友信息的时候开始发送时间戳参数。我阅读了很多帖子并搜索了信息,但没有找到对我的情况有用的信息。谢谢。

func getFriends() {
    DispatchQueue.global(qos: .background).async {
        let params = ["fields": "id, first_name, last_name, name, email, picture"]
        let graphRequest = FBSDKGraphRequest(graphPath: "/me/friends", parameters: params)
        let connection = FBSDKGraphRequestConnection()
        connection.add(graphRequest, completionHandler: { (connection, result, error) in
            if error == nil {
                guard let userData = result as? [String : Any] else { return }
                guard let jsonData = userData["data"] as? [[String : Any]] else { return }
                debugPrint("facebook data", jsonData)
                do {
                    let data = try JSONSerialization.data(withJSONObject: jsonData, options: JSONSerialization.WritingOptions.prettyPrinted)
                    let jsonDecoder = JSONDecoder()
                    let friends = try jsonDecoder.decode(Array<FacebookFriendModel>.self, from: data)
                    debugPrint("friends", friends.count)
                    self.saveFriends(friends)
                } catch {
                    debugPrint(error.localizedDescription)
                }
            } else {
                print("Error Getting Friends \(error?.localizedDescription ?? "")");
            }
        })

        connection.start()
    }
}

最佳答案

The question is, can I only ask for "new friends"? For example, I requested a list of all friends on October 25, and to not ask the list of all friends of the user to be next time, I send timestamp parameters from when I need information about user's friends.

不,那种功能根本不可用。

Facebook 故意不提供两个用户成为好友的信息。

关于ios - 仅从 Facebook iOS 获取新 friend ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46932915/

相关文章:

ios - 单击表格 View 单元格行时如何推送新的 View Controller ?

iphone - 如何在 ios 4 中以编程方式将图像数组添加到 Imageview?

swift - Swift 命令行程序中的 CFRunLoop

php - Graph API,列出最后的帖子,包括帖子的总喜欢数

php - 为什么我不能通过图形 API 在 Facebook 上发布到公共(public)组? (#200) 用户未授权

java - Android Facebook 集成 - 预定义墙贴

objective-c - 如何将 NSDictionary 的值转换为 NSString?

ios - 在 UITableView 数组中保存 Firebase 结构 [Swift 4]

ios - 内部名称 swift 2.0+?

ios - 获取 URLSession.shared.dataTask 的 http 响应状态码