Manspof
Manspof

Reputation: 357

get high quality facebook profile picture with cordova plugin

I'm developing ionic 2 app. I'm trying to get high quality image and then resize it to avatar photo.

My code:

 _FBUserProfile() {

return new Promise((resolve, reject) => {
  Facebook.api('me?fields=id,name,email,first_name,last_name,picture.width(600).height(600).as(picture_small),picture.width(360).height(360).as(picture_large)', [])
    .then((profileData) => {
      console.log(JSON.stringify(profileData));
      return resolve(profileData);
    }, (err) => {
      console.log(JSON.stringify(err));
      return reject(err);
    });
});

}

But, the photo isn't good quality, since I guess I did something wrong with the resize in this line:

picture.width(600).height(600).as(picture_small),picture.width(360).height(360).as(picture_large)', [])

How can I get good quality of the photo?

Upvotes: 10

Views: 2440

Answers (2)

Raj Nandan Sharma
Raj Nandan Sharma

Reputation: 3862

If you want to get the public profile picture of the user and you know the user id from the api call then use this url for picture

profileData.picture="https://graph.facebook.com/"+profileData.id+"/picture?width=1024&height=1024";

Upvotes: 10

EddyTheDove
EddyTheDove

Reputation: 13259

You've got a couple of solutions, like using type large

id,name,email,first_name,last_name,picture.type(large)

As explained here: https://developers.facebook.com/docs/graph-api/reference/user/picture/

Upvotes: 6

Related Questions