Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 383
Manspof Avatar asked Mar 07 '17 05:03

Manspof


2 Answers

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";
like image 117
Raj Nandan Sharma Avatar answered Nov 17 '22 16:11

Raj Nandan Sharma


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/

like image 24
EddyTheDove Avatar answered Nov 17 '22 17:11

EddyTheDove