Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change height/width of profile picture from Facebook API user/taggable friends

I can query Facebook's API to get a list of taggable friends with:

FB.api('me/taggable_friends', function (taggable) {
    document.getElementById('friends').innerHTML = JSON.stringify(taggable);
});

But this only returns a url to a tiny profile picture. I'd like to get the full sized picture.

Are non-app users' pictures still avalible in Facebook Open Graph v2.0?

The above link has a comment by Simon Cross that says "You can use ...? Fields=width(n),height(n) to get a larger image" but I can't figure out the correct syntax.

Does anyone know how this works?

Thanks

like image 611
Andrew Avatar asked May 29 '14 01:05

Andrew


2 Answers

I have been struggling with the same issue, the Facebook docs on this are awful, but finally I worked it out:

    FB.api(
        "/me/taggable_friends?fields=name,picture.width(100), picture.height(100)",
        function (response) {
          if (response && !response.error) {
            // Do what you like with the response data here response.data;
            callback();
          } else {
            console.log(response);
          }

        }
    );

Hoe that helps!

like image 77
Jozef Avatar answered Sep 24 '22 10:09

Jozef


The format of @Jozef's answer did not work for me. This worked instead:

fields=name,picture.width(100).height(100)

I'm using the nodejs module facebook-node-sdk, so perhaps my issue was specific to that. Here is a full example:

   FB.api('me/taggable_friends', {
       fields:         'name,picture.width(100).height(100)',
       limit:          20,
       access_token:   req.session.access_token
   }, function (result) {
       if(!result || result.error) {
           return false;
       }
       d = {
         friends: result.data,
       };

      res.render('myview', d);
   });

That will return a limit of 20 friends, with 100x100 px thumbnails.

like image 25
Banjer Avatar answered Sep 25 '22 10:09

Banjer