【问题标题】:Event when click on Like button点击Like按钮时的事件
【发布时间】:2012-02-21 00:44:15
【问题描述】:

点击 LIKE 按钮时我无法进行活动。

这是我的脚本:

<html xmlns:fb="http://ogp.me/ns/fb#">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Caron mazda</title>
</head>
<body>

<div id="fb-root"></div>
<script>
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/fr_FR/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

FB.Event.subscribe('edge.create',
    function(response) {
        alert('You liked THISSS Yeaa');
    }
);

 alert('I am an alert box!'); // dont work ?? probleme avec le edge.create !
</script>


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

</body>
</html>

你能修复我的代码以举办活动吗?脚本有什么问题?

【问题讨论】:

    标签: facebook button facebook-like


    【解决方案1】:

    您没有初始化 SDK。只需使用 Facebook 默认实现:

    <html xmlns:fb="http://ogp.me/ns/fb#">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Caron mazda</title>
    </head>
    <body>
    <div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : 'YOUR_APP_ID', // App ID
          channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
          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
        FB.Event.subscribe('edge.create',
            function(response) {
                alert('You liked THISSS Yeaa');
            }
        );
      };
    
      // 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>
    
    <fb:like-box href="http://www.facebook.com/ConcessionnaireCaronMazda#!/ConcessionnaireCaronMazda" width="292" show_faces="false" stream="false" header="false"></fb:like-box>
    
    </body>
    </html>
    

    【讨论】:

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