通过 firebase 登录获取更大的 Facebook 图片 [英] Get larger facebook image through firebase login
本文介绍了通过 firebase 登录获取更大的 Facebook 图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 firebase 通过 Facebook 登录用户.这一切都很好,我可以获得用户 FB 个人资料图片,尽管它很小.有人可以告诉我如何获得更大的,我正在使用的代码:
I am using firebase to login a user through facebook. This all works fine and I can get the users FB profile image, although it is to small. Can somebody tell me how to get a larger one, the code I am using:
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
}
}
}
}
(这是快速完成的)
推荐答案
根据 Facebook 文档 在个人资料图片上,您应该能够通过将 width
和 height
附加到 url 来指定大小:
According to the Facebook documentation on Profile Picture, you should be able to specify the size by appending width
and height
to the url:
let photoUrl = profile.photoURL?.absoluteString + "?width=(width)&height=(height)"
或通过指定类型:
let photoUrl = profile.photoURL?.absoluteString + "?type=large"
这篇关于通过 firebase 登录获取更大的 Facebook 图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文