我在swift 4中使用Facebook SDK。它返回optional("xx")
userId而不是"xx"
普通ID。我正在弄清楚如何从结果中提取值。
let connection = GraphRequestConnection()
var request = GraphRequest.init(graphPath: "me")
request.parameters = ["fields":"email,first_name,last_name,picture.width(1000).height(1000)"]
connection.add(request, completion: {
(response, result) in
switch(result){
case .success(let res):
print(res)
if let responseDictionary = res.dictionaryValue {
let id = responseDictionary["id"] as? String
print(id)
let first = responseDictionary["first_name"] as? String
print(first)
if let picture = responseDictionary["picture"] as? NSDictionary {
if let data = picture["data"] as? NSDictionary{
if let profilePicture = data["url"] as? String {
print(profilePicture)
}
}
}
}
break
case .failed(_):
break
}
它将id打印为Optional("2013340245575263")