2011-08-02 45 views

回答

4

混淆一半的Facebook上的JavaScript SDK在客戶端的系統上運行(也稱爲Web瀏覽器)。該SDK託管在Facebook上,您只需要將其包含在<script src='http://connect.facebook.net/en_US/all.js'></script>中即可。您不需要將其上傳到您的服務器。

您可以使用JavaScript客戶端的SDK


如果是XFBML你感到迷惑:它是由JavaScript SDK轉換爲HTML和CSS 客戶端

+0

你知道從哪裏下載呢? FB有很多鏈接,但我沒有看到一個鏈接實際下載它。 :) – Genadinik

+0

哦,我看到了 - 大聲笑,你改變了你的答案:) – Genadinik

+0

@Genadinik是的,我看到我的史詩般的錯誤後改變它。大約一年前,我已經使用了SDK。 – 2011-08-02 16:50:00

3

沒有必要將JavaScript SDK上傳到您的服務器(除非您想堅持特定的版本)。如果你願意,你可以只引用一個被Facebook擔任,就像任何其他腳本:

<div id="fb-root"></div> 
<script src="http://connect.facebook.net/en_US/all.js"></script> 
<script> 
    FB.init({ 
    appId : 'your app id', 
    status : true, // check login status 
    cookie : true, // enable cookies to allow the server to access the session 
    xfbml : true // parse XFBML 
    }); 
</script> 

或者您可以asyncronously加載:

<div id="fb-root"></div> 
<script> 
    window.fbAsyncInit = function() { 
    FB.init({appId: 'your app id', status: true, cookie: true, 
      xfbml: true}); 
    }; 
    (function() { 
    var e = document.createElement('script'); e.async = true; 
    e.src = document.location.protocol + 
     '//connect.facebook.net/en_US/all.js'; 
    document.getElementById('fb-root').appendChild(e); 
    }()); 
</script> 
相關問題