通过firebase登录获取更大的Facebook图像 [英] Get larger facebook image through firebase login
本文介绍了通过firebase登录获取更大的Facebook图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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 文档,您应该可以通过追加 width
和 height $ c来指定大小$ c>到url:
let photoUrl = profile.photoURL?.absoluteString +?width = \(width) & height = \(height)
或指定类型:
let photoUrl = profile.photoURL?.absoluteString +?type = large
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
}
}
}
}
(This is done in swift)
解决方案
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)"
or by specifying the type:
let photoUrl = profile.photoURL?.absoluteString + "?type=large"
这篇关于通过firebase登录获取更大的Facebook图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文