Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook edge.create event not firing on like box

I had a page with a simple Facebook like button and I needed to know when the user liked the page so I used the edge.create event to do this which all worked fine. I now need to add a like Box plugin to the page to like the client's facebook page and again I need to be notified when someone clicks the like button. However, the subscribe event never fires. Any idea what might be the problem? I am using the xfbml code to add the like box.

like image 308
Karl Gohery Avatar asked Sep 12 '11 15:09

Karl Gohery


1 Answers

It appears to be a bug. Here's a link to official credible sources:

http://developers.facebook.com/bugs/310763168934515

And my jsFiddle here to demonstrate: http://jsfiddle.net/dmcs/3D2GD/1/

EDIT

I've found the solution!

First I put my code onto my own domain rather than jsFiddle to do better testing, however my first try failed as if the code was still on jsFiddle. So I troubleshot the situation further.

Then for the app setting I specified I went in and specified the WebSite url on https://developers.facebook.com/apps/{APP_ID}/summary

Here's my code

<html>
<head>
    <title>Like Box example</title>
</head>

<body>

<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
    FB.init({
        appId: '{APP_ID}'
    });
    FB.Event.subscribe('edge.create', function(response) {
        alert('You liked the URL: ' + response);
    });
};

(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id; //js.async = true;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId={APP_ID}";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));


</script>

<div class="fb-like-box" data-href="http://www.facebook.com/Cocacola" data-width="292" data-show-faces="true" data-stream="true" data-header="true"></div>

</body>
</html>
like image 85
DMCS Avatar answered Oct 13 '22 09:10

DMCS