Iframe Like button not firing edge.create
Asked Answered
W

1

8

I dont want to use xfbml. I need to use iframe like button like below. But that's not firing edge.create.

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
// initalize your Facebook App
  FB.init({
    appId  : '113869198637480',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
  });
// subscribe to the event
FB.Event.subscribe('edge.create', function(response) {
  alert('you liked this');
});
FB.Event.subscribe('edge.remove', function(response) {
  alert('you unliked this');
});
</script>

<iframe id="test" src="http://www.facebook.com/plugins/like.php? 
       href=http://google.com/&amp;
       layout=button_count&amp;
       show_faces=false&amp;
       width=50&amp;
       action=like&amp;
       colorscheme=light&amp;
       height=21" 
       scrolling="no" frameborder="0" 
       style="border:none; overflow:hidden; width:50px;  
              height:21px;" 
       allowTransparency="true">
Wachtel answered 16/10, 2012 at 8:48 Comment(3)
Not, it’s not possible using the iframe version.Oaf
yes, don´t use the iframe version ;)Wuhan
You must use xfbml. Period.Fair
S
8

This is completely expected; the javascript callbacks are only available when using the Javascript version of the social plugins, including the Like Button.

This is mentioned in the Like Button documentation:

How do I know when a user clicks a Like button?

If you are using the XFBML version of the button, you can subscribe to the 'edge.create' event through FB.Event.subscribe.

When you include the Like button as an iFrame directly, there's no way for the event from Facebook's servers to be propagated back to your javascript code - the Facebook Javascript SDK handles this communication when using the XFBML version of the Like button

Sarnoff answered 29/12, 2012 at 20:48 Comment(3)
Thanks, I know that, I still need a way (even ugly and hacky) to detect iFrame like buttonsOrlon
That's not possible unfortunatelySarnoff
If you can get the exact coordinates (x,y) of the like button you might get the client mouse click coordinates and assume it is a Like click.Cns

© 2022 - 2024 — McMap. All rights reserved.