2011-05-14 80 views

回答

2

你需要开始使用图形API,这里有一个快速工作例子,让你开始:

<!doctype html> 
<html xmlns:fb="http://www.facebook.com/2008/fbml"> 
<head> 
<title>Facebook Javascript SDK</title> 
</head> 
<body> 
    <div><fb:login-button perms=""></fb:login-button></div> 

    <div id="friends"></div> 


    <div id="fb-root"></div> 
    <script> 
     window.fbAsyncInit = function() { 
     FB.init({ 
      appId : 'APP_ID', 
      cookie : true, 
      status : true, 
      xfbml : true 
     }); 

     FB.Event.subscribe('auth.login', function(response) { 
      window.location.reload(); 
     }); 

     FB.api('/me/friends',function(resp) { 
      if(resp && resp.data.length) { 
       var html = '<ul>'; 
       for(var i=0; i<resp.data.length; i++) { 
        html += '<li><img src="http://graph.facebook.com/' + resp.data[i].id + '/picture?type=small" />' + resp.data[i].name + '</li>'; 
       } 
       html += '</ul>'; 
       document.getElementById('friends').innerHTML = html; 
      } 
     }); 
     }; 

     (function() { 
     var e = document.createElement('script'); 
     e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
     e.async = true; 
     document.getElementById('fb-root').appendChild(e); 
     }()); 
    </script> 
</body> 
</html> 

与应用程序ID只需更换,你是好去!

1

你有权利,你可能不应该再使用fbml,但所有来自“社交插件”的标记仍然会被鼓励(即like button)。

无论是过时与否,我更喜欢有布局的全面控制研究我的应用程序 - 而是使用<fb:name...标签,你可以得到所有的朋友列表,从“http://graph.facebook.com/UID/friends”和解析结果JSON。 (在PHP-SDK中:$fb->api("/me/friends");)。

相关问题