2

It looks like:

        FB.Event.subscribe('edge.create', function(href, widget) {
            alert("Hi");
        });

works for everybody except me! Here is my code:

         <html xmlns:fb="https://www.facebook.com/2008/fbml">
                               .
                               .
                               .
         <body>
         <div id="section1">    
     <div id="fb-root"></div>
         <script src="http://connect.facebook.net/en_US/all.js"></script>
         <script>
     window.fbAsyncInit = function() {
            FB.init({
               appId :'xxx',
               status : true, 
               cookie : true,
               xfbml : true, 
               oauth : true 
            });
            FB.Event.subscribe('edge.create', function(href, widget) {
               alert("Hi");
            });
          });

          (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/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
          }(document, 'script', 'facebook-jssdk'));</script>

          <fb:like href="mysite" send="false" width="450" show_faces="false" font="tahoma"></fb:like>


     </div> 

I just need a simple way to check if the like button was clicked to show a form on the page! Any Suggestions? Thanks

4

1 回答 1

3

您甚至可以在同一页面上检测多个喜欢。我们经常使用它,请查看以下代码段。

window.fbAsyncInit = function() {
 FB.init({appId: 'YOUR_FACEBOOK_APP_ID', status: true, cookie: true, xfbml: true});
 FB.Event.subscribe('edge.create', function(href, widget) {

  // START: LOGIC For detecting multiple likes on the same page
   if(href == "LINK_1_ON_THEPAGE') {
       alert('User Like is for Link1');
   } else if (href == "LINK_2_ON_THEPAGE') {
       alert('User Like is for Link2');
   }
  // END: LOGIC For detecting multiple likes on the same page

 });
};
于 2012-08-20T01:45:59.530 回答