1

我目前正在使用以下代码从用户个人资料中检索所有照片

FB.api('/me/albums?fields=id,name', function(response) {
  //console.log(response.data.length);
  for (var i = 0; i < response.data.length; i++) {
    var album = response.data[i];

    FB.api('/' + album.id + '/photos', function(photos) {
      if (photos && photos.data && photos.data.length) {
        for (var j = 0; j < photos.data.length; j++) {
          var photo = photos.data[j];
          // photo.picture contain the link to picture
          var image = document.createElement('img');
          image.src = photo.picture;
          document.body.appendChild(image);
          image.className = "border";

          image.onclick = function() {
            //this.parentNode.removeChild(this);
            document.getElementById(info.id).src = this.src;
            document.getElementById(info.id).style.width = "220px";
            document.getElementById(info.id).style.height = "126px";
          };
        }
      }
    });

  }
});

但是,它返回的照片质量很差,基本上就像缩略图一样。如何从相册中检索更大的照片。

通常对于个人资料图片,我使用 ?type=large 返回一个不错的个人资料图片

但是 type=large 不适用于相册中的照片,并且一旦我指定照片网址,是否有办法从 facebook 获取 zip 格式的照片,因为我希望用户能够下载照片。

4

1 回答 1

3

你需要改变:

image.src = photo.picture;

到:

image.src = photo.source;

源成员是指向完整照片的链接,而不是图片成员提供的缩略图链接。

参考链接: https ://developers.facebook.com/docs/reference/api/photo/

于 2012-09-03T03:50:11.720 回答