2011-05-12 63 views
2

我不能得到這個工作。我試圖展示like this(請參閱「發送到許多」部分的圖像圖像)。我收到消息「發生錯誤,請稍後再試。」Facebook的iframe彈出

代碼:

window.fbAsyncInit = function() { 
    FB.ui({title: 'title', display: 'iframe', 
     method: 'apprequests', message: 'check this out.' 
    }); 
} 

EDIT1: 彈出窗口顯示,但它裏面有沒有好友列表,但上述消息。

編輯2: 當然,我的應用程序在首次啓動時請求用戶朋友列表的權限。

+0

你試着刪除'顯示:「iframe''?我認爲你不需要它。 – MatejB 2011-05-13 08:29:33

+0

嗯,我想彈出顯示在iframe中,所以我實際上需要它:) – marek 2011-05-15 18:00:41

回答

0

我測試了你的代碼,並且我得到了所有用戶的對話加載。

我會建議檢查你的應用程序ID,以確保它是正確的。

下面是我使用的代碼:

  //run the script code to get the facebook javascript sdk 
      (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); 
      }()); 

      //run when sychronisation of facebook javascript sdk is finished 
      window.fbAsyncInit = function(){ 
       //initialise the application 
       FB.init({appId: '<?=APPLICATION_ID?>', status: true, cookie: true, xfbml: true, oauth: true}); 
       FB.ui({title: 'title', display: 'iframe', method: 'apprequests', message: 'check this out.' 
        }); 
      }; 
+0

這可能是一些Facebook的JS問題(這經常發生) - 現在我不記得我做了什麼來照顧這個問題,但我確定我的應用ID是正確的。無論如何,謝謝你。 – marek 2011-08-02 13:20:36

0

你應該使用功能getLoginStatus,可以肯定的是,FB.init功能已經完成加載。

我剛剛解決了同樣的問題是這樣的:

注意,我使用jQuery

<script type="text/javascript"> 
     $(document).ready(function() { 
      FB.init({ appId: 'APP_ID', status: true, cookie: true, xfbml: true, oauth: true }); 
      FB.getLoginStatus(function (response) { 
       FB.ui({ title: 'Invite friends', display: 'iframe', method: 'apprequests', message: 'check this out.' }); 
      }); 
     }); 
    </script> 
<div id="fb-root"></div>