从swift中获取FB中的用户信息
答
请试试这个。
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)
})
}
}
}
+0
你能解决我在那里完成的方式吗?我已经提取了所有其他数据,只有现在我需要获取图片。提前谢谢@ Keyur Hirani –
+0
可能会听到许可问题。将picture.type(大)替换为picture.width(480).height(480) –
+0
我做到了...仍显示为空。 @ Keyur Hirani –
参见:http://stackoverflow.com/questions/28333951/getting-profile-picture-with-swift-through-facebook-graph-api-return-unsupporte –
你有任何错误,同时获取图片? – Birendra
不,任何错误!它显示除了显示图片为空之外的所有内容... @ Birendra –