获取fbrell.com上的示例工作?

时间:2012-02-28 11:06:12

标签: javascript facebook

我试图让这个例子有效,但我不知道如何使用它。 如果我只复制和粘贴代码本身不起作用。我明白缺少什么,但是什么?

代码可在此处找到:

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

1 个答案:

答案 0 :(得分: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>