[英]FaceBook like-button callbacks not working
誰能告訴我為什么下面的類似按鈕代碼無法使用回調? 據我所知,該代碼是JavaScript中的標准設置。 初始化第一個按鈕,然后異步加載API,並提供回調函數。
<div id="fb-root"></div>
<script>
window.fbAsyncInit=function(){
FB.init({
appId:'',//App ID
status:false,// check login status
cookie:true,// enable cookies to allow the server to access the session
xfbml:true// parse XFBML
});
// Additional initialization code here
FB.Event.subscribe('edge.create', function(response) {
//alert("user_id1:<?php echo $user_id1; ?>, user_id2:<?php echo $user_id2; ?>");
/*var data={
action:"ap_buttons_give_points",
author_id:<?php echo $author_id; ?>,
post_id:<?php echo $post_id; ?>,
type:"like"
}
jQuery.post("<?php echo $ajax_url; ?>",data,function(resp){
});*/
alert('You just liked the page!');
});
FB.Event.subscribe('edge.remove', function(response) {
/*var data={
action:"ap_buttons_take_points",
author_id:<?php echo $author_id; ?>,
post_id:<?php echo $post_id; ?>,
type:"like"
}
jQuery.post("<?php echo $ajax_url; ?>",data,function(resp){
//alert("fb remove:"+resp);
});*/
alert('You just unliked the page!');
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
對我來說,這是唯一一次發生在我使用iframe版本的“贊”按鈕時。 我發現該版本的回調根本不起作用。 如果是這種情況,您將要使用XFBML或HTML5使用此處找到的Javascript SDK版本:
<fb:like send="true" width="450" show_faces="true"></fb:like>
要么
<div class="fb-like" data-send="true" data-width="450" data-show-faces="true"></div>
是的,代碼看起來還不錯。 我有點同樣的問題,但只有fb之類的按鈕,即iframe版本。 我在您的示例中沒有看到fb按鈕,所以我不知道您使用的是哪個按鈕。因此,根據我的經驗,請使用類似標准的fb。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.