Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notify facebook application admin when comments are posted using social plugin

Is it possible to send notification to facebook application admins when comments are posted using facebook social comments plugin?

Comment plugin is set up this way:

<meta property="fb:admins" content="111,222,333" />
<meta property="fb:app_id" content="123456789" />

<div id="fb-root"></div>
<script>
    (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/en_US/all.js#xfbml=1&appId=123456789";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>

<div class="fb-comments" data-href="http://example.com" data-num-posts="2" data-width="470" notify="true"></div>

<script>
    window.fbAsyncInit = function(){ 
             FB.Event.subscribe('comment.create', function(response){
                   alert(response); 
             });
    };
</script>

Event subscribe works pretty good in this example(shows response alert), but is it possible to send notification to application administrators?

Your help would be appreciated.

like image 675
Bounce Avatar asked Mar 27 '12 17:03

Bounce


People also ask

How do I notify comments on Facebook?

You won't get notified when someone replies to a comment. Go to the post that you'd like to turn notifications on or off. Tap then tap More and select Turn on notifications for this post or Turn off notifications for this post.

How do you add a Facebook comment to a plugin?

Upon activation, you need to visit Settings » Lazy FB Comments to configure the plugin. To use Facebook comments on your website, you will have to create a Facebook app and then add the application ID to the plugin's settings page.

How do I change Comment settings on Facebook?

Click Settings & Privacy, then select Settings. In the left menu, click Privacy, then select Public Posts. Next to Comment Ranking, click Edit. Select On or Off.


1 Answers

I set up a simple PHP script to email me whenever a comment is posted. The PHP is like this:

<?php
mail('[email protected]','facebook_notification.php',
'Comment activity on http://example.com'.$_GET['path']);

and this JavaScript passes the URL of the comment page to the PHP script:

FB.Event.subscribe('comment.create', function(response){
var dummyImage = new Image;
dummyImage.src = 'http://example.com/facebook_notification.php?path='+response.href.replace('http://','');
});

I can easily add more addresses if I need to.

like image 75
Liam Avatar answered Oct 04 '22 04:10

Liam