[英]Facebook Callback not being triggered
I am trying to have a Facebook "like" trigger a callback, but it seems to either not work at all or work sporadically. 我试图让Facebook“喜欢”触发回调,但似乎要么根本不起作用,要么零星地工作。 Here is my code: 这是我的代码:
LIKE BUTTON HTML 像按钮HTML
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
<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/en_US/all.js#xfbml=1&appId=123456789";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="http://flevy.com/powerpoint-plugin" data-send="false" data-layout="box_count" data-width="50" data-show-faces="false"></div>
CALL BACK JAVASCRIPT 回调JAVASCRIPT
window.fbAsyncInit = function() {
FB.init({appId:'123456789', status:true, cookie:true, xfbml:true});
try {
FB.Event.subscribe('edge.create', function(href, widget) {
deliverEmail();
});
} catch (e) {}
};
I've also tried just this: 我也试过这个:
FB.Event.subscribe('edge.create', function(href, widget) {
deliverEmail();
});
Here is the live version if you want to test it out: http://flevy.com/powerpoint-plugin 如果您想测试一下,这是实时版本: http : //flevy.com/powerpoint-plugin
One other question. 另一个问题。 I created a Facebook app tied to the URL and am referencing its appID in the code. 我创建了一个绑定到URL的Facebook应用程序,并在代码中引用其appID。 Is it necessary to do this--ie create a FB app for the page just to embed a "like" button? 是否有必要这样做 - 即为页面创建一个FB应用程序只是为了嵌入“喜欢”按钮?
Thanks. 谢谢。
edge.create
is fired only when you use xfbml version of like button. 只有在使用xfbml版本的like按钮时edge.create
触发edge.create。
Change 更改
<div class="fb-like" data-href="http://flevy.com/powerpoint-plugin" data-send="false" data-layout="box_count" data-width="50" data-show-faces="false"></div>
to 至
<fb:like href="http://flevy.com/powerpoint-plugin" send="false" layout="box_count" width="50" show_faces="false"></fb:like>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.