如何从相册通过Facebook图表api获取大图片 [英] how to get large pictures from photo album via facebook graph api
问题描述
我正在使用以下代码从用户个人资料中检索所有照片
I am currently using the following code to retrieve all the photos from a user profile
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";
};
}
}
});
}
});
但是,它返回的照片质量差,基本上就像缩略图。如何检索较大
but, the photos that it returns are of poor quality and are basically like thumbnails.How to retrieve larger photos from the albums.
一般用于个人资料图片我使用?type = large,返回体面的个人资料图片
Generally for profile picture I use ?type=large which returns a decent profile image
但是,如果从相册
的照片中,type = large不起作用,并且还有一种方法可以从zip格式获取照片一旦我指定照片网址,我希望用户能够下载照片。
but the type=large is not working in the case of photos from photo albums and also is there a way to get the photos in zip format from facebook once I specify the photo url as I want users to be able to download the photos.
推荐答案
您需要更改: / p>
You need to change:
image.src = photo.picture;
to:
image.src = photo.source;
源成员是指向完整照片的链接,而不是由图片会员提供的缩略图链接。
The source member is a link to the full photo, rather then a thumbnail link provided by the picture member.
参考链接:
https://developers.facebook.com/docs/reference/api/photo/
这篇关于如何从相册通过Facebook图表api获取大图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!