谁能告诉我为什么这对我不起作用?
示例页面在这里
http://totalcommunitycollegemove.com/post-438.html
window.fbAsyncInit = function() {
FB.init({appId: '194189377275548', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
function catchCommentAdd()
{
$.ajax({
type: "POST",
url: "ajaxCommentCount.php",
data: "id=<?php echo $_GET['id']; ?>&direction=up",
dataType: "json"
});
return true;
}
function catchCommentDelete()
{
$.ajax({
type: "POST",
url: "ajaxCommentCount.php",
data: "id=<?php echo $_GET['id']; ?>&direction=down",
dataType: "json"
});
return true;
}
FB.Event.subscribe('comments.create', function(response) {
alert(response);
catchCommentAdd();
});
最佳答案
我遇到了同样的问题,但也许找到了解决方案(在我的测试站点上有效)。似乎事件名称“comments.create”是错误的。正确的(或至少有效的)事件是“comment.create”(没有 s)
这是我的代码片段:
<script>
window.fbAsyncInit = function() {
FB.init({
appId: 'APP_ID',
status: true,
cookie: true,
xfbml: true
});
FB.Event.subscribe('comment.create', function(response) {
alert(response.commentID);
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
<fb:comments href="YOUR_URL" num_posts="5" width="500" ></fb:comments>
关于javascript - Facebook Event.subscribe comments.create 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5130883/