通过firebase登录获取更大的Facebook图像 [英] Get larger facebook image through firebase login

查看:162
本文介绍了通过firebase登录获取更大的Facebook图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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 文档,您应该可以通过追加 width height 到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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆