2010-10-13 22 views
1

我在我的應用上使用pyfacebook,但我遇到了顯示xfbml的問題 例如,我必須使用iframe來顯示按鈕或類似框。用pyfacebook顯示xfbml的問題

什麼奇怪: 1)在登錄頁面的正確顯示,我只是在其他頁面上的問題(登錄後)

2)我使用的FB.init部分是

<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US" type="text/javascript"></script> 
<script type="text/javascript">FB.init("{{ apikey }}", '/static/xd_receiver.html'); 

而Facebook上的文檔的參數是:

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 
}); 

3)當我改變FB.init官方FB之一,應用程序不工作了。 (例如我不能登出使用此

<a href="#" onclick="javascript:FB.Connect.logoutAndRedirect('/')">Logout</a> 

我是比較新的FB的東西,所以我可能混合的東西了,但我只是想在不修改太多,以顯示我的應用程序正確FBML 。服務器端

回答

1

我想你混淆了Facebook的old javascript API他們new javascript API

由於新的API頁面上提到的,用這個做初始化:

<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> 

對於註銷,你會想這樣的事情:

<a href="#" onclick="javascript:FB.logout(function(response) {window.location.href = '/';})">Logout</a>