FB评论插件-检测页面上的评论 [英] FB Comments Plugin - Detect comment on page

查看:87
本文介绍了FB评论插件-检测页面上的评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何检测使用评论插件"在页面上发表评论的时间?我目前正在使用Facebook PHP SDK,阅读其中说我需要JS SDK的Facebook文档,但对于如何完成我想做的事情还不清楚.

How can I detect when a comment is made on my page with the Comments Plugin? I'm currently using the Facebook PHP SDK, reading the Facebook documentation it says I need the JS SDK, but it's not really clear on how you accomplish what I want to do.

推荐答案

我想这很简单:

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'YOUR_APP_ID', // App ID
      channelURL : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      oauth      : true, // enable OAuth 2.0
      xfbml      : true  // parse XFBML
    });

    FB.Event.subscribe('comment.create',
        function(response) {
            alert('A new comment has been added!');
        }
    );

  };

  // Load the SDK Asynchronously
  (function(d){
     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     d.getElementsByTagName('head')[0].appendChild(js);
   }(document));
</script>

文档: 1 - 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆