title: display photos from facebook with javascript api?
body: <p>I want to display photos from one of my facebook albums on my webpage with the javascript api.
  I can read the album names with the below code, but how can I then display the photos of one of the albums? </p>
  
  <pre><code>FB.api('/myfacebookid/albums', function(response) {
  
      var ul = document.getElementById('albums');
      for (var i=0, l=response.data.length; i&lt;l; i++) {
        var
          album = response.data[i],
          li = document.createElement('li'),
          a = document.createElement('a');
        a.innerHTML = album.name;
        a.href = album.link;
        li.appendChild(a);
        ul.appendChild(li);
      }
    });
  </code></pre>
  
  <p>Any input appreciated, thanks!</p>
  
  <p>OK, now I have this code instead:</p>
  
  <pre><code>    FB.api('/142461229141170/albums?fields=id,name', function(response) {
       if (response &amp;&amp; response.data &amp;&amp; response.data.length){
           console.log(response)
  
    for (var i=0; i&lt;response.data.length; i++) {
      var album = response.data[i];
  
      if (album.name == 'Profile Pictures'){
  
        FB.api('/'+album.id+'/photos', function(photos){
          if (photos &amp;&amp; photos.data &amp;&amp; photos.data.length){
            for (var j=0; j&lt;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;
              $('#foton').append(image);
            }
          }
        });
  
        break;
      }
    }
     }
  });
  </code></pre>
  
  <p>I guess Im doing something wrong..still! This is displaying the photos from the Profile Pictures album but I had to change it to $('#foton').append(image); . If I look at the log it gets 4 objects.</p>
  
  <p>If I change to a different album eg - Manmade Photos or Cover Photos it stops working.</p>
  
  <p>And also if I change the userId from above(the above is a PAGE id) to my personal facebook id then it stops working aswell.</p>
  
  <p>Im really trying to understand how this works, because I also want to get the feed and some other stuff after this, and I guess that it works the same way as this? Thanks a lot, guys!</p>