如何通过 Graph API 获取用户的性别或电子邮件等特定字段
How to get specific fields like gender or email of a user through Graph API
我有这个代码:
import FacebookCore
let connection = GraphRequestConnection()
connection.add(GraphRequest(graphPath: "/me")) { httpResponse, result in
switch result {
case .success(let response):
print("Graph Request Succeeded: \(response)")
case .failed(let error):
print("Graph Request Failed: \(error)")
}
}
connection.start()
登录成功后执行。现在我得到的只是基本信息,例如姓名或 ID。
不过,我需要性别和电子邮件...所以我尝试了这个:
let params = ["fields": "id, name, gender, email"]
然后:
connection.add(GraphRequest(graphPath: "/me", parameters: params)) { httpResponse, result in
仍然,我得到了相同的数据,只有 id
和 name
在响应中。
我有这个代码:
import FacebookCore
let connection = GraphRequestConnection()
connection.add(GraphRequest(graphPath: "/me")) { httpResponse, result in
switch result {
case .success(let response):
print("Graph Request Succeeded: \(response)")
case .failed(let error):
print("Graph Request Failed: \(error)")
}
}
connection.start()
登录成功后执行。现在我得到的只是基本信息,例如姓名或 ID。
不过,我需要性别和电子邮件...所以我尝试了这个:
let params = ["fields": "id, name, gender, email"]
然后:
connection.add(GraphRequest(graphPath: "/me", parameters: params)) { httpResponse, result in
仍然,我得到了相同的数据,只有 id
和 name
在响应中。