Change the height / width of the profile image from API users / friends of the API user

I can request the Facebook API to get a list of friends with tags:

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

But this only returns the URL to the tiny profile. I would like to get a full size picture.

Are non-user photos still available on Facebook Open Graph v2.0?

The link above has a comment by Simon Cross who says: β€œCan you 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

+7
facebook facebook-graph-api facebook-javascript-sdk
source share
4 answers

I was struggling with the same problem, the docs on Facebook about this are terrible, but finally I worked:

  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); } } ); 

Help, help!

+16
source share

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

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

I am using the nodejs module facebook-node-sdk , so maybe my problem was specific to this. Here is a complete 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); }); 

This will return a limit of 20 friends, with thumbnails of 100x100 pixels.

+12
source share

In version 2.5, I could not set the width and height of the image, however, if you make such a call, it will work.

 me/taggable_friends?fields=picture.width(500).height(500) 

The image you are returning is at least as large as you are, without scaling, but it is better than too small.

+2
source share

This is the code for iOS:

 [FBRequestConnection startWithGraphPath:@"/me/taggable_friends" parameters:@{@"fields" : @"name,picture.width(500).height(500)"} HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { /* handle the result */ if(!error){ NSArray *friends = result[@"data"]; // do something with the friends list } else{ // show the error } }]; 
0
source share

All Articles