Facebook之Social Plugins

悠悠隱於市發表於2011-03-24

Facebook之Social Plugins

什麼是Social Plugin
引用
Social plugins
    Social plugins enable you to provide engaging social experiences to your users with just a line of HTML. Because the plugins are served by Facebook, the content is personalized to the viewer whether or not they have signed into your site.

簡單地說:你想在你網站的某個網頁上顯示一個按鈕、一小塊html程式碼等來連結Facebook應用,那麼只要引入facebook的API和一段fbml就可以達到目的。
Php程式碼:
  1. <html>   
  2.     <body>   
  3.         <div id="fb-root"></div>   
  4.     </body>   
  5. </html>   
  6. <script>   
  7.   // 116344281725102 是一個facebook應用的app id.   
  8.   window.fbAsyncInit = function() {   
  9.     FB.init({appId: '116344281725102', status: true, cookie: true,   
  10.              xfbml: true});   
  11.   };   
  12.   (function() {   
  13.     var e = document.createElement('script');    
  14.     e.async = true;   
  15.     //e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';   
  16.     e.src = 'http://connect.facebook.net/en_US/all.js';   
  17.     document.getElementById('fb-root').appendChild(e);   
  18.   }());   
  19. </script>   
  20. <fb:login-button></fb:login-button>  
瀏覽器中執行看看結果 :

相關文章