Get Larger Facebook Image Through Firebase Login

Android : How to get larger profile pic from Facebook using FirebaseAuth?

It is not possible to obtain a profile picture from Firebase that is larger than the one provided by getPhotoUrl(). However, the Facebook graph makes it pretty simple to get a user's profile picture in any size you want, as long as you have the user's Facebook ID.

String facebookUserId = "";
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
ImageView profilePicture = (ImageView) findViewById(R.id.image_profile_picture);

// find the Facebook profile and get the user's id
for(UserInfo profile : user.getProviderData()) {
// check if the provider id matches "facebook.com"
if(FacebookAuthProvider.PROVIDER_ID.equals(profile.getProviderId())) {
facebookUserId = profile.getUid();
}
}

// construct the URL to the profile picture, with a custom height
// alternatively, use '?type=small|medium|large' instead of ?height=
String photoUrl = "https://graph.facebook.com/" + facebookUserId + "/picture?height=500";

// (optional) use Picasso to download and show to image
Picasso.with(this).load(photoUrl).into(profilePicture);

Get larger facebook image through firebase login

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 login with facebook -how to get larger profile image -javascript

You have to get the facebook User id from the user providerData object:

https://graph.facebook.com/{{authFacebook.user.providerData[fbIndex].uid}}/picture?width=800

What is the best practice to retrieve Facebook user picture with Firebase in Swift?

I found out that Firebase's photoURL is Facebook's Graph API URL: http://graph.facebook.com/user_id/picture. So, to get other sizes, all I need to do is to append a query string like ?type=normal to the photoURL.

To use GraphRequest, consider @jnpdx's suggestion:

Seems like you have at least a couple of options: 1) Use the
GraphRequest and don't set your User model until you get the result
back. 2) Set your User model as you are now and then update it with a
new URL once your GraphRequest comes back.

Facebook Profile Picture Link Changes?

So somehow I finally figured this out today. Essentially the graphAPI spits back several pieces with one being a picture piece. This looks like the links I posted above https://platform-lookaside.fbsbx.com/platform/profilepic

THIS CHANGES!!! Not sure how often, but do NOT use this as eventually it will be a dead link.

However, what I missed was that you can use the ID that the graphAPI spits back instead and use the following link:

http://graph.facebook.com/{your_id_goes_here}/picture?type=large&redirect=true&width=500&height=500

More information can be found in this other post:

Get user profile picture by Id



Related Topics



Leave a reply



Submit