Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting facebook thumbnail profile picture

Does anyone know how I can get a thumbnail/avatar of a facebook user using the javascript sdk?

I know to get the full size picture I can do the folllowing:

//Get a list of all the albums
FB.api('/me/albums', function (response) {
  for (album in response.data) {

    // Find the Profile Picture album
    if (response.data[album].name == "Profile Pictures") {

      // Get a list of all photos in that album.
      FB.api(response.data[album].id + "/photos", function(response) {

        //The image link
        image = response.data[0].images[0].source;

      });
    }
  }
});

Not sure on how to get the thumbnail/avatar size. Something like a 50x50 size

like image 813
adit Avatar asked Apr 24 '11 17:04

adit


3 Answers

You can also just use an <img> tag with a special URL to do the same thing:

<img src="http://graph.facebook.com/<UID>/picture?type=square" />
like image 135
Jimmy Sawczuk Avatar answered Oct 05 '22 19:10

Jimmy Sawczuk


As of August 2012, you can define custom dimensions for the user thumbnail, e.g. https://graph.facebook.com/USER_ID/picture?width=WIDTH&height=HEIGHT. Find out more, https://developers.facebook.com/docs/reference/api/using-pictures/.

like image 31
Gajus Avatar answered Oct 05 '22 20:10

Gajus


I did the following to accomplish the same thing:

FB.api(
      {
       method: 'fql.query',
       query: 'SELECT name,email,pic_small FROM user WHERE uid=' + uid
       // uid is the id of the user.
      },
      function(response) {
         var user = response[0];
         // user.pic_small contains the url for the small sized profile pic
      });
like image 28
Arihant Nahata Avatar answered Oct 05 '22 21:10

Arihant Nahata