我很难将个人资料详细信息(名称,电子邮件个人资料图片和ID)的Facebook图形API响应存储到变量中,以后可以创建到对象中。我收到此错误
Value of type 'Any?' has no member 'dictionaryValue'
这是我的方法
func getUseProfile() {
let graphRequest : GraphRequest = GraphRequest(graphPath: "/me", parameters: ["fields":"id, email, name, picture.width(480).height(480)"], httpMethod: .get)
graphRequest.start(completionHandler: { (connection, result, error) -> Void in
if error != nil {
print("Error took place: \(String(describing: error))")
}
else {
print("Print entire fetched result: \(String(describing: result))")
print("Print id: \(String(describing: "id"))")
if let responseDictionary = result.dictionaryValue {
let fbEmail = responseDictionary["email"] as? String
print(fbEmail)
let fbName = responseDictionary["name"] as? String
print(fbName)
let fbId = responseDictionary["id"] as? String
print(fbId)
if let picture = responseDictionary["picture"] as? NSDictionary {
if let data = picture["data"] as? NSDictionary{
if let profilePicture = data["url"] as? String {
print(profilePicture)
}}}}
}
})
}
典型图形API响应:
({
email = "test@gmail.com";
id = 2624827091891056;
name = "Test Test";
picture = {
data = {
height = 480;
"is_silhouette" = 0;
url = "https://platform-lookaside.fbsbx.com/platform/profilepic/?
asid=2624827091891056&height=480&width=480&ext=1572756671&hash=AeQLcrXR_f-mejoi";
width = 480;
};
};
})