Swift 为什么FBSDKGraphRequest(graphPath:“me”,参数:params)会被调用。只调用一次

Swift 为什么FBSDKGraphRequest(graphPath:“me”,参数:params)会被调用。只调用一次,swift,facebook,login,Swift,Facebook,Login,我正在尝试获取我的测试用户的某些Facebook信息,我用来获取用户信息的方法似乎只在注册时调用,但在登录时没有调用。每次用户使用Facebook登录时,我都要返回这些信息。我在didpletewith方法中使用了以下方法 let params = ["fields" : "email, name, friendlists"] let graphRequest = FBSDKGraphRequest(graphPath: "me", parameters: params)

我正在尝试获取我的测试用户的某些Facebook信息,我用来获取用户信息的方法似乎只在注册时调用,但在登录时没有调用。每次用户使用Facebook登录时,我都要返回这些信息。我在
didpletewith
方法中使用了以下方法

let params = ["fields" : "email, name, friendlists"]
        let graphRequest = FBSDKGraphRequest(graphPath: "me", parameters: params)
        _ = graphRequest?.start(completionHandler: { (connection, result, error) in
            if error != nil {
                print(error!.localizedDescription)
                return
            }

            if let result = result as? [String:Any]{
                guard let email = result["email"] as? String else {
                    return
                }

                guard let username = result["name"] as? String else {
                    return
                }

                guard let friendList = result["friendlists"] as? String else {
                    return
                }

                print(email, username, friendList)
            }
        })
我还应该用别的方法吗


更新:我相信我没有使用正确的参数来获取好友列表。

您的代码没有问题。可能您没有在等待完成块的执行。只需等待几秒钟,块就可以执行。

“我相信我也没有使用正确的参数来获取好友列表。”-好友列表只提供用户创建的列表的名称,其他什么都没有。是的,你是对的,发现我在graphPath中提供了不正确的参数来访问好友列表。