【问题标题】:Facebook likebox event on clicking button点击按钮上的 Facebook likebox 事件
【发布时间】:2011-11-02 18:17:42
【问题描述】:

我正在尝试使用 SDK Facebook 来检测对likebox 的“like”按钮的点击并调用一个函数,但它不起作用。 这是我的代码:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    </body>

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'xxxx', // App ID
      channelURL : 'xxxx/facebook/channel.html', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      oauth      : true, // enable OAuth 2.0
      xfbml      : true  // parse XFBML
    });

    // Additional initialization code here
  };

  // 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 = "//connect.facebook.net/en_US/all.js";
     d.getElementsByTagName('head')[0].appendChild(js);
   }(document));
</script>
<script type="text/javascript">
FB.Event.subscribe('edge.create',
    function(response) {
        alert('You liked the URL: ' + response);
    }
);
</script>

<fb:like-box href="http://www.facebook.com/MarwenClubiiste" width="292" show_faces="false" stream="false" header="false"></fb:like-box>

</html>

请帮忙,我真的需要这个

【问题讨论】:

    标签: javascript html facebook api sdk


    【解决方案1】:

    Like 框有一个已知错误,如果用户从 facebook 注销并且必须登录到 LIKE 页面,edge.create 事件将不起作用。 但是,如果用户已经登录,它可以正常工作。 这里提到了这个错误:

    https://github.com/facebook/connect-js/issues/82

    http://forum.developers.facebook.net/viewtopic.php?id=75166

    Like 按钮没有此错误,并且在两种情况下都会触发事件。 您可能需要将 LikeBox 替换为 Like 按钮 + 您自己的一些自定义 HTML。

    尝试使用 facebook JS 的非异步加载。这里有更多帮助:

    http://forum.developers.facebook.net/viewtopic.php?id=87926

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-29
      • 2015-08-28
      • 2011-12-30
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多