【发布时间】:2018-07-03 06:12:35
【问题描述】:
我一直在使用以下代码从 Facebook 图表中获取一些详细信息,
func getFBUserData(){
let parameters = ["fields": "id, first_name, picture.type(large), email, last_name, gender"]
let graphRequest = FBSDKGraphRequest(graphPath: "/me", parameters: parameters)
graphRequest?.start { (connection, result, error) in
if let error = error {
print(error.localizedDescription)
print("Data Not Received")
} else {
let userID = FBSDKAccessToken.current().userID
let URL = "http://graph.facebook.com/\(userID)/picture?type=large"
print(URL)
let json = JSON(result)
print("FB Json \(json)")
let fid = json["id"].stringValue
let email = json["email"].stringValue
let name = json["first_name"].stringValue
let lName = json["last_name"].stringValue
let sex = json["gender"].stringValue
var imgURLString = "http://graph.facebook.com/" + fid + "/picture?type=large"
print(imgURLString)
self.UploadSocialAccount(name: name,lname: lName, email: email, picture: imgURLString, gender: sex)
let manager = FBSDKLoginManager()
manager.logOut()
}
}
}
由于某种原因,我能够获得除电子邮件之外的所有其他详细信息。 需要在函数中更改什么,才能获取所有参数?
【问题讨论】:
-
用户是否授予您的应用电子邮件权限?
-
我认为没有.. 如何授予应用电子邮件权限?在这个函数中..?
-
您在用户登录时请求用户许可
-
那么,我应该在 info.plist 中设置它吗?
标签: ios swift facebook facebook-graph-api