2011-04-14

FaceBook API for JavaScript 安裝

使用 Facebook api 需先將下方的code放至網頁中<body>...</body>中

lt;div id="fb-root"></div>

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId  : 'you app id',
      //channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File for x-domain communication
      status : true, // check login status
      cookie : true, // enable cookies to allow the server to access the session
      xfbml  : true  // parse XFBML
    });
  };

  (function() {

    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/zh_TW/all.js";
     ref.parentNode.insertBefore(js, ref);

  }(document));

</script>


fb-root 是用來存放 fb api 的 mothe。
<div id="fb-root"></div>

上述語法中的 "//connect.facebook.net/zh_TW/all.js" 是fb 提供的js檔,zh_TW 為繁體中文,en_US 為英文。