Submit Your Article Forum Rules

Results 1 to 2 of 2

Thread: How to get notify when comments are posted by users on a website using Social Plugin?

  1. #1

    How to get notify when comments are posted by users on a website using Social Plugin?

    I have defined a Facebook Application Id and comments are showing up in the Comment Moderation Tool. Still we have to go there to see if a comment was posted or not because I haven't found the way to automate the notification yet.


    The comment box is set up that way


    In the header


    HTML Code:
    <meta property="fb:app_id" content="my_app_idd"/><meta property="fb:admins" content="101xxxxxx"/>

    Before the fb comment


    Code:
    <script>
     window.fbAsyncInit = function() {
         FB.init({ appId: '338850122832287',
            status: true,
            cookie: true,
            xfbml: true});
     
        FB.Event.subscribe('comment.create',
            function(response) {
            
            }
        );
     
     };
     </script>

    And the box


    HTML Code:
    <fb:comments notify="true" href="http://www.xxxxx111.cl/xxxxxxx-50.aspx" num_posts="5" width="730">
    What am I missing to get, somehow, notified when a comment is posted ?
    Jean-Luc Corobori WebDesign
    Working in the Concepcion area, Chile, since 1999
    Follow us on Twitter

  2. #2
    Got it working eventually. Not the way I really wanted (that is posting a message on the wall) but sending an email


    Code:
     window.fbAsyncInit = function() {
         FB.init({ appId: 'YOU_APP_ID',
            status: true,
            cookie: true,
            xfbml: true});
    
    
        FB.Event.subscribe('comment.create',
            function (response) {
                console.log("comment created");
                var commentQuery = FB.Data.query("SELECT text, fromid FROM comment WHERE post_fbid='" + response.commentID +
                    "' AND object_id IN (SELECT comments_fbid FROM link_stat WHERE url='" + response.href + "')");
                var userQuery = FB.Data.query("SELECT name FROM user WHERE uid in (select fromid from {0})", commentQuery);
                FB.Data.waitOn([commentQuery, userQuery], function () {
                    var commentRow = commentQuery.value[0];
                    var userRow = userQuery.value[0];
                    /* console.log(userRow.name + " (id: " + commentRow.fromid + ") posted the comment: " + commentRow.text); */
                    trackcomments(response['commentID'], response['href'], 'create', commentRow.text, userRow.name, commentRow.fromid);
                   
                });
            });
    
    
    };
    
    
    function trackcomments(_commentid, _address, _action,
     _commentMessage, _userName, _userId) {
        /* Replace FBComment.aspx by any server script sending the email*/
        $.ajax({
            type: 'POST',
            url: '/FBComment.aspx', 
            data:
                 {
                     commentId: _commentid,
                     pageUrl: _address,
                     actionTaken: _action,
                     userName: _userName,
                     userId: _userId,
                     commentMessage: _commentMessage
                 },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log(errorThrown);
            },
            success: function (result) {
                console.log("successfully received callback");
            }
        });
    }
    Jean-Luc Corobori WebDesign
    Working in the Concepcion area, Chile, since 1999
    Follow us on Twitter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •