通过 firebase 登录获取更大的 facebook 图片
Get larger facebook image through firebase login
我正在使用 firebase 通过 facebook 登录用户。这一切都很好,我可以获得用户的 FB 个人资料图像,尽管它很小。谁能告诉我如何获得更大的,我使用的代码:
override func viewDidLoad() {
let loginButton = FBSDKLoginButton()
loginButton.readPermissions = ["public_profile", "email"]
loginButton.delegate = self
self.view.addSubview(loginButton)
}
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError?) {
let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString)
FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in
if let user = FIRAuth.auth()?.currentUser {
for profile in user.providerData {
let photoUrl = profile.photoURL?.absoluteString //SMALL IMAGE
}
}
}
}
(这是在 swift 中完成的)
根据个人资料图片上的 Facebook documentation,您应该可以通过将 width
和 height
附加到 url 来指定尺寸:
let photoUrl = profile.photoURL?.absoluteString + "?width=\(width)&height=\(height)"
或通过指定类型:
let photoUrl = profile.photoURL?.absoluteString + "?type=large"
一旦 FB 用户通过身份验证,使用 FBSDKGraphRequestConnection
创建一个 FBSDKGraphRequest
来获取用户 FBid,使用它您可以通过在此处插入 id 来获取用户个人资料图片:
https://graph.facebook.com//picture?type=large&return_ssl_resources=1
您也可以使用 ?width=<width>&height=<height>
而不是 type=large
也是
获得照片 Url 后,只需将 "?width=400&height=400"
添加到照片 url 即可。这里height=width=400,你可以选择自己的高度和宽度。肯定有效!
我正在使用 firebase 通过 facebook 登录用户。这一切都很好,我可以获得用户的 FB 个人资料图像,尽管它很小。谁能告诉我如何获得更大的,我使用的代码:
override func viewDidLoad() {
let loginButton = FBSDKLoginButton()
loginButton.readPermissions = ["public_profile", "email"]
loginButton.delegate = self
self.view.addSubview(loginButton)
}
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError?) {
let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString)
FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in
if let user = FIRAuth.auth()?.currentUser {
for profile in user.providerData {
let photoUrl = profile.photoURL?.absoluteString //SMALL IMAGE
}
}
}
}
(这是在 swift 中完成的)
根据个人资料图片上的 Facebook documentation,您应该可以通过将 width
和 height
附加到 url 来指定尺寸:
let photoUrl = profile.photoURL?.absoluteString + "?width=\(width)&height=\(height)"
或通过指定类型:
let photoUrl = profile.photoURL?.absoluteString + "?type=large"
一旦 FB 用户通过身份验证,使用 FBSDKGraphRequestConnection
创建一个 FBSDKGraphRequest
来获取用户 FBid,使用它您可以通过在此处插入 id 来获取用户个人资料图片:
https://graph.facebook.com//picture?type=large&return_ssl_resources=1
您也可以使用 ?width=<width>&height=<height>
而不是 type=large
也是
获得照片 Url 后,只需将 "?width=400&height=400"
添加到照片 url 即可。这里height=width=400,你可以选择自己的高度和宽度。肯定有效!