2011-05-24 82 views
0

我試圖在畫布應用程序內彈出一個請求對話框(朋友列表),但我遇到了麻煩,而且我在教程中找不到任何幫助。應用程序內的Facebook請求對話框

這裏在認證之後進行代碼等

<script src="http://connect.facebook.net/en_US/all.js"></script> 
<script> 
    FB.init({ 
    appId : '[**myid**]', 
    status : true, // check login status 
    cookie : true, // enable cookies to allow the server to access the session 
    xfbml : true // parse XFBML 
    }); 
</script> 
<button id="send-to-many">Send to Many</button> 
<div id="fb-root"></div> 
<script> 
document.getElementById('send-to-many').onclick = function() { 
FB.ui({ 
    method: 'apprequests', 
    message: 'You should learn more about blabla].', 
    }, Log.info.bind('send-to-many callback')); 
} 
</script> 

任何想法或如何啓動JS在FB帆布的例子?

+1

您有什麼問題?控制檯中是否有任何javascript錯誤? – bkaid 2011-05-25 00:00:32

+0

未捕獲ReferenceError:未定義日誌 – RealFantasy 2011-05-25 00:10:17

+0

你知道任何一個好的例子可以如何集成一個朋友請求popup-link嗎? – RealFantasy 2011-05-25 00:11:05

回答

0

問題是FB.ui()函數中的第二個參數應該是回調函數。嘗試刪除它,並將其替換爲null或定義的函數或內聯函數。如果您確實需要調用Log.info.bind,請確保函數已定義並且包含定義腳本。現在,請嘗試如下所示:

<script type="text/javascript"> 
document.getElementById('send-to-many').onclick = function() { 
FB.ui({ 
    method: 'apprequests', 
    message: 'You should learn more about blabla].', 
    }, function(response) { 
    //Log.info.bind('send-to-many callback')); 
    alert('callback called'); 
    }) 
} 
</script> 

Facebook文檔包含您正在嘗試執行的示例和代碼。檢查他們的requests documentation

0

如果你想使用Log.info.bind,將其更改爲console.log()

<script> 
document.getElementById('send-to-many').onclick = function() { 
FB.ui({ 
    method: 'apprequests', 
    message: 'You should learn more about blabla].', 
    }, Log.info.bind('send-to-many callback')); 
} 
</script> 
相關問題