Facebook edge.create event not firing on like box

▼魔方 西西 提交于 2019-12-09 12:42:43

问题


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.


回答1:


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>



回答2:


just need to replace code:

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

with this one :

<fb:like-box href="http://www.facebook.com/jsfiddle" 
colorscheme="light" show_faces="false" header="false" stream="false" 
show_border="false"></fb:like-box>

and it works ok.



来源:https://stackoverflow.com/questions/7390433/facebook-edge-create-event-not-firing-on-like-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!