【问题标题】:Facebook send button integration error for websiteFacebook 为网站发送按钮集成错误
【发布时间】:2012-02-26 22:02:39
【问题描述】:

我正在尝试使用 Facebook 应用程序将 Facebook 发送按钮集成到我的网站中。我在 Facebook 中创建了一个应用程序,并在网站链接中提供了我的网站网址:

我在我的网页中使用以下代码:

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: '1xxxxxxxxxx', status: true, cookie: true, xfbml: true});
  };
  (function() {
    var e = document.createElement('script');
    e.type = 'text/javascript';
    e.src = document.location.protocol + '//connect.facebook.net/en_GB/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

<script>
  function trace(message) {
      var div = document.getElementById('trace');
      div.innerHTML = div.innerHTML + message + '<br/>';
  }
</script>

它没有显示用于向朋友发送邮件的登录窗口。

【问题讨论】:

    标签: facebook login send


    【解决方案1】:

    您缺少发送插件的标记。它看起来像这样:

    &lt;div class="fb-send" data-href="http://example.com"&gt;&lt;/div&gt;

    js.src = 行也应该是这样的:

    js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&amp;appId={APPID}";

    【讨论】:

      【解决方案2】:

      我添加了 javascriptSDK,然后从 facebook 发送按钮代码。总代码如下:在我的脑海中:

      <script>window.fbAsyncInit = function() { FB.init({ appId : '1xxxxxxxxxxxxx', // App ID channelUrl : 'http://example.com/', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); }; // Load the SDK Asynchronously (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "http://connect.facebook.net/en_US/all.js"; d.getElementsByTagName('head')[0].appendChild(js); }(document)); </script><script>(function(d, s, id) {
      //在正文部分

       <div id="fb-root"></div> <br/> <div class="fb-send" data-href="http://example.com/"></div>
      

      【讨论】:

        猜你喜欢
        • 2011-12-23
        • 1970-01-01
        • 2015-09-21
        • 1970-01-01
        • 1970-01-01
        • 2012-07-17
        • 2012-03-06
        • 2013-09-02
        • 1970-01-01
        相关资源
        最近更新 更多