简体   繁体   English

获取Facebook缩略图个人资料图片

[英]getting facebook thumbnail profile picture

Does anyone know how I can get a thumbnail/avatar of a facebook user using the javascript sdk? 有谁知道我如何使用javascript sdk获取Facebook用户的缩略图/头像?

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 大小约为50x50

您也可以只使用<img>标记和特殊URL来执行相同的操作:

<img src="http://graph.facebook.com/<UID>/picture?type=square" />

As of August 2012, you can define custom dimensions for the user thumbnail, eg https://graph.facebook.com/USER_ID/picture?width=WIDTH&height=HEIGHT . 从2012年8月开始,您可以为用户缩略图定义自定义尺寸,例如https://graph.facebook.com/USER_ID/picture?width=WIDTH&height=HEIGHT Find out more, https://developers.facebook.com/docs/reference/api/using-pictures/ . 了解更多信息, https://developers.facebook.com/docs/reference/api/using-pictures/

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

Since you have the UID of the person, you can easily get the image. 由于您拥有此人的UID,因此可以轻松获取图像。 For example, my profile image URL should be graph.facebook.com/v2.8/1375341351/picture?type=small (now change the type parameter and enjoy different sizes.. cheers... sizes can be small, normal, album, large, square 例如,我的个人资料图片网址应为graph.facebook.com/v2.8/1375341351/picture?type=small(现在更改type参数并享受不同的尺寸。。欢呼...尺寸可以小,普通,相册,大,方形

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM