Skip to content Skip to sidebar Skip to footer

Embed Facebook Albums Into Website

I have used graph api to fetch the albums, I got all the albums into my website but the positions of the albums changing when I refresh the page. why it should happening? I am atta

Solution 1:

The data being returned isn't always in the same order so it needs sorted if you want consistent results.

This seems to work well(but it could be cleaned up a bit):

  $.getJSON(albumIdsUrl, function(data) {
   var len = data.data.length;
   data.data.sort(function(a, b)
    {
        if (a.id == b.id) return0;
        if (a.id < b.id)
            return -1;
        elsereturn1;
    });
   for(var i=0;i<len;i++){
        var aid = data.data[i].id;
        getAlbumCoverPhoto(data.data[i].cover_photo, data.data[i].id, data.data[i].name, data.data[i].count);
   }
}); 

Post a Comment for "Embed Facebook Albums Into Website"