gpt4 book ai didi

json - 从 Facebook sdk 获取个人资料图片 url

转载 作者:行者123 更新时间:2023-11-30 10:06:48 26 4
gpt4 key购买 nike

我找不到获取 Facebook 个人资料图片网址的解决方案。

当我通过 Facebook 登录时,我使用此方法通过 Facebook graph api 获取个人资料信息:

func getFBUserData() {
// Create request for user's Facebook data
let request = FBSDKGraphRequest(graphPath:"me", parameters:["fields": "id, name, first_name, middle_name, last_name, email, picture.type(large)"])

// Send request to Facebook
request.startWithCompletionHandler {

(connection, result, error) in

if error != nil {
// Some error checking here
}
else {

print(result)


if let userData = result as? [String:AnyObject] {

// Access user data
let username = userData["first_name"] as! String


}

}

}
}

我可以轻松解析名字、电子邮件等,但当涉及到图片网址时,我不知道如何影响该数据。以下是我对 Facebook api 的回复:

{
email = "dailocle@hotmail.com";
"first_name" = Loc;
id = 123456765432457654;
"last_name" = Le;
"middle_name" = Dai;
name = "Loc Dai Le";
picture = {
data = {
"is_silhouette" = 0;
url = "https://scontent.xx.fbcdn.net/hprofile-xat1/v/t1.0-1/p200x200/12246670_10207807554127440_7406917875415466413_n.jpg?oh=d394b200091f8973645300054e6b32b8&oe=572E6626";
};
};
}

最佳答案

使用 FBSDKProfile 类的 imageURLForPictureMode:size 便捷方法。

let pictureURL = FBSDKProfile().imageURLForPictureMode(.Normal, size: CGSize(width: 100, height: 100))

关于json - 从 Facebook sdk 获取个人资料图片 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35503037/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com