【问题标题】:Fetching user's info from FB in swift快速从FB获取用户信息
【发布时间】:2017-01-10 09:09:44
【问题描述】:

我已经在 Swift 3 中从我的应用程序完成了 FB 登录。现在,我需要从 Facebook 获取个人资料图片。谁能给我 Swift 3 中的解决方案?

【问题讨论】:

标签: ios swift facebook facebook-graph-api


【解决方案1】:

请试试这个。

let login = FBSDKLoginManager()

        login.logIn(withReadPermissions: ["email"], from: self) { (result, error) -> Void in

            if (error != nil) {

                self.view.makeToast("Error")
            }
            else if (result?.isCancelled)! {

                self.view.makeToast("Cancel")
            }
            else {

                if (FBSDKAccessToken.current() != nil) {

                    FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"id,interested_in,gender,birthday,email,age_range,name,picture.width(480).height(480)"]).start(completionHandler: { (connection, result, error) -> Void in

                        print(result)
})
                }
            }
        }

【讨论】:

  • 你能解决我在上面做的方法吗?我已经获取了所有其他数据,只是现在我需要获取图片。提前感谢您@Keyur Hirani
  • 可能是权限问题。将 picture.type(large) 替换为 picture.width(480).height(480)
猜你喜欢
  • 2020-04-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-04
  • 1970-01-01
相关资源
最近更新 更多