Плагин комментариев Facebook: comment.create и comment.remove не работают для зарегистрированных пользователей - PullRequest
1 голос
/ 12 ноября 2011

Когда пользователь еще не вошел в Facebook или на странице уже есть комментарий, код выполняется правильно; однако, когда пользователь уже вошел в систему и добавляет первый комментарий, comment.create и comment.remove обычно не запускаются:

<div id="fb-root"></div>
<script type="text/javascript">
<!--
window.fbAsyncInit = function() {
FB.init({appId: 'FACBOOKAPPID', oauth: true, status: true, cookie: true, xfbml: true});

FB.Event.subscribe('comment.create', function(response) {
    alert(response.commentID);         
});
FB.Event.subscribe('comment.remove', function(response) {
    alert(response.commentID);
}); 
};

(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js#xfbml=1';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
//-->
</script> 

<fb:comments href="URL" num_posts="1" width="500"></fb:comments>

Предложения

1 Ответ

0 голосов
/ 28 сентября 2012
<script>
//INCLUDE THE SCRIPT FIRST
(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/it_IT/all.js#xfbml=1&appId=APP ID";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));


//INITIALIZE THE OBJECTS
window.fbAsyncInit = function() {
    FB.init({
        appId:  'APP ID',
        status: true,
        cookie: true,
        xfbml:  true,
        oauth: true
    });

    //AND THOSE WILL FIRE THE EVENTS :)

    FB.Event.subscribe('comment.create',
        function (response) {
            console.log('create', response);
        });
    FB.Event.subscribe('comment.remove',
        function (response) {
           console.log('remove', response);
        });

};
</script>

<fb:comments class="fb-comments" href="URL" data-num-posts="2" data-width="630"  notify="true"  migrated="1"></fb:comments>
...