2

I'm using that snippet below to get info of my contacts, works fine, I just need to know how to change the size of the picture I get, currently I'm getting a very small pic. I searched through Facebook docs and found nothing.

    FB.api('/me/friends', { fields: 'id, name, picture', limit: 3 },  function(response) 
    {
           if (response.error) 
           {
               alert(JSON.stringify(response.error));
           } 
           else 
           {    
               alert("Loading friends...");
               console.log("fdata: " + response.data);
               response.data.forEach(function(item) 
               {           
                     // feeding my html                
               });
           }


    });

Thanks!

Ps.: I'm using a Phonegap plugin to use Facebook API. Probably, the JS methods I'm calling are calling Java methods, so, I don't know which especifically API I'm using, but seems to me the default Graph Api.

Marcelo Assis
  • 5,136
  • 3
  • 33
  • 54
  • Possible duplicate of [Facebook Graph API : get larger pictures in one request](http://stackoverflow.com/questions/10650730/facebook-graph-api-get-larger-pictures-in-one-request) – bummi Mar 04 '16 at 06:54

2 Answers2

2

I use /user_id/picture?type=large for profile pics.

http://developers.facebook.com/tools/explorer/135669679827333/?method=GET&path=732484576%2Fpicture%3Ftype%3Dlarge

refer to http://developers.facebook.com/docs/reference/api/#pictures

in your case do not call the pictures of the friends, use the id instead

in your html build the image

<image src="https://graph.facebook.com/user_id/picture?type=large&return_ssl_results=1" />

Example:

<div id="friends"></div>
<script>
    FB.api('/me/friends', { fields: 'id, name', limit: 3 },  function(response) 
    {
           if (response.error) 
           {
               alert(JSON.stringify(response.error));
           } 
           else 
           {    
               alert("Loading friends...");
               console.log("fdata: " + response.data);
               response.data.forEach(function(item) 
               {           
                document.getElementById('friends').innerHTML+='<image src="https://graph.facebook.com/'+item['id']+'/picture?type=large&return_ssl_results=1" />'; 
                    document.getElementById('friends').innerHTML+='<br />'+item['name']+'';          
               });
           }


    });
</script>
phwd
  • 19,975
  • 5
  • 50
  • 78
ShawnDaGeek
  • 4,145
  • 1
  • 22
  • 39
  • 1
    I need to get a *list* of contacts and *other info*, not only one image form one contact. – Marcelo Assis Jun 09 '12 at 18:46
  • you can loop the user id into that image build for as many images as you wish, i would not suggest more than 1,000 at a time. – ShawnDaGeek Jun 09 '12 at 18:49
  • 1
    Thanks! Now that your edited your answer, made more sense to me. I felt like a dumbass now. If I do not find anything more like I'm searching for, I gonna use it. – Marcelo Assis Jun 09 '12 at 19:31
  • i just tested this method with a user access token on my website http://anotherfeed.com/?ref=logo auth required with perms but it will load the 3 friends on right hand column of my page. – ShawnDaGeek Jun 09 '12 at 19:46
1

You can go with either of the following 4 based on your needs

       FB.api('id?fields=picture&type=large');

or

       FB.api('id?fields=picture&type=small');

or

       FB.api('id?fields=picture&type=square');

or

       FB.api('id?fields=picture&type=normal');
user229044
  • 232,980
  • 40
  • 330
  • 338