2012-02-28 49 views
-1

我想让这个例子工作,但我不知道如何使用它。 如果我只复制并粘贴,代码本身不起作用。我明白缺少某些东西,但是什么?在fbrell.com上获取示例以运行?

代码是在这里找到:

http://www.fbrell.com/fb.ui/apprequests?autoRun=false

+0

在致电FB.ui你必须加载和初始化的Facebook的JavaScript SDK。如果您遇到任何困难,请参阅https://developers.facebook.com/docs/reference/javascript/并发帖。 – 2012-02-28 11:17:17

+0

我尝试过,但仍然无法使用。完整的代码应该是什么样子? – 2012-02-28 11:20:46

回答

4

首只例如:

<div id="fb-root"></div> 
<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : '<APP_ID>', 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
    }); 

    // Additional initialization code here 
    }; 

    // Load the SDK Asynchronously 
    (function(d){ 
    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/en_US/all.js"; 
    ref.parentNode.insertBefore(js, ref); 
    }(document)); 
</script> 

<h1>requests</h1> 
<button id="send-to-many">Send to Many</button> 

<script> 
document.getElementById('send-to-many').onclick = function() { 
    FB.ui({ 
    method: 'apprequests', 
    message: 'You should learn more about the Platform.' 
    }, function(response) { 
     console.log(response); 
    }); 
} 
</script> 
相关问题