0

我是 html、facebook graph api、jquery 的新手。

我有以下代码来获取 facebook 粉丝页面(不是一般个人资料)中的所有相册,以简单的格式显示它,我在 chrome 的开发者控制台中没有看到任何错误,但没有显示照片。关于如何查看 facebook 粉丝页面上的所有照片的任何想法?

<!DOCTYPE html>
<html>
 <head>
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/
     1.4.2/jquery.min.js"></script>
 </head>
  <body onLoad="fbFetch()">


  <script>
     function fbFetch(){

      var url = "https://graph.facebook.com/160407767374259/photos?limit=5?callback=";


        $.getJSON(url,function(json){
           var html = "<ul>";


        $.each(json.data,function(i,fb){
          html += "<li><img alt='"+ fb.from.name +"' height='" + fb.height + "' width='" +
    fb.width + "' src='" + fb.picture + "'/></li><div style='clear:both;'>&nbsp;</div>";
});

html += "</ul>";


$('.facebookfeed').animate({opacity:0}, 500, function(){
 $('.facebookfeed').html(html);
 });
 $('.facebookfeed').animate({opacity:1}, 500);
 });
 };

4

1 回答 1

2

您缺少重要的 DOM 就绪包装器

<script>
$(function(){ 
    // code here
}); 
</script>

http://docs.jquery.com/Tutorials:Introducing_$(document).ready()

工作演示

于 2012-11-26T15:54:55.977 回答