javascript - Facebook Event.subscribe comments.create 不工作

标签 javascript facebook facebook-javascript-sdk

谁能告诉我为什么这对我不起作用?

示例页面在这里

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/

相关文章:

java - Facebook 登录后将 Activity 重定向到 Frontpage Activity

Facebook 提要对话框 : allow user to select destination page or group

javascript - 指定的版本无效,Facebook 分享插件错误

javascript - 使用 JavaScript 的 Selenium Webdriver,如何使用 chrome.exe 的特定路径启动 Chrome?

javascript - extjs 4 : a form panel having 2 column and can insert 2 type fields

javascript - 如何处理函数中的返回值?

facebook - 解析 Facebook 登录始终显示 Facebook 页面 "you have already authorized this app"

ios - 在 iOS Swift 上发布到 Instagram 屏幕

ios - 需要 fb :like in UIWebView with edge. 创建/删除事件触发的工作示例

javascript - div 类名 ="filter-bubbles five-sixths column"