Nav
Nav

Reputation: 10442

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.

Generally for profile picture I use ?type=large which returns a decent profile image

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.

Upvotes: 1

Views: 4562

Answers (1)

RGdev
RGdev

Reputation: 179

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.

Reference link: https://developers.facebook.com/docs/reference/api/photo/

Upvotes: 3

Related Questions