簡體   English   中英

獲取Facebook縮略圖個人資料圖片

[英]getting facebook thumbnail profile picture

有誰知道我如何使用javascript sdk獲取Facebook用戶的縮略圖/頭像?

我知道要獲得完整尺寸的圖片,我可以進行以下操作:

//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;

      });
    }
  }
});

不確定如何獲取縮略圖/頭像大小。 大小約為50x50

您也可以只使用<img>標記和特殊URL來執行相同的操作:

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

從2012年8月開始,您可以為用戶縮略圖定義自定義尺寸,例如https://graph.facebook.com/USER_ID/picture?width=WIDTH&height=HEIGHT 了解更多信息, https://developers.facebook.com/docs/reference/api/using-pictures/

我做了以下事情來完成同樣的事情:

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

由於您擁有此人的UID,因此可以輕松獲取圖像。 例如,我的個人資料圖片網址應為graph.facebook.com/v2.8/1375341351/picture?type=small(現在更改type參數並享受不同的尺寸。。歡呼...尺寸可以小,普通,相冊,大,方形

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM