2012-01-26 29 views
6

我正在尋找使用Facebook Graph API獲取用戶頭像的最佳方式。通過文檔獲取Facebook信息更高分辨率的圖片

看,我發現這一點:

可以指定你想要的類型參數圖片尺寸,這應該是正方形的一個(50×50),小(50個像素寬,可變高度),正常(100個像素寬,可變高度)和大(約200像素寬,高度可變)

我的問題是:有沒有辦法讓比200像素分辨率更高的個人資料圖片?

我最近發現了這個解決辦法,但我不知道我怎麼可以檢查用戶是否有另一種語言的專輯:

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

可能重複的[獲取全尺寸個人資料圖片](http://stackoverflow.com/questions/8574759/getting-full-size-profile-picture) – Brad

回答

7

這是直接從文檔

您可以使用類型參數 指定想要的圖片大小,它應該是方形(50x50),小(50像素寬,變量 高),普通(100像素寬,可變高度)和大(大約 200像素寬,變黑GHT):

http://graph.facebook.com/{ID}/picture?type=large

現在,有沒有從調用到圖形以便獲得更大的尺寸阻止你的,但你必須有一個有效的用戶訪問令牌這樣做。

+0

假設我有一個有效的訪問令牌來做相應的請求,我要調用哪種方法來獲取更大尺寸的圖片? – elauria

+0

您已經在上面的原始問題中發佈了關於如何獲得更大尺寸的代碼。 – DMCS

+0

我知道,但我也需要用不同語言閱讀個人資料圖片專輯的最佳方式。 – elauria

4

您可以通過使用Facebook JavaScript API得到完整的圖像質量:

FB.api('/{ID}?fields=picture.height(2048)', function(response){ 
    $("#profile_pic").attr("src",response.picture.data.url); 
}); 

假設你有一個

<img id="profile_pic" src=""/> 

身體某處

0

我在做。

FB.api('/'+id+'/picture?type=large&width=300&height=300', function(response){ 
    if(response && !response.error){ 
     // do your stuff. 
    } 
}) 

可以定義widthheight爲適合您的任何值。您將在其文檔中看到更多選項。