Notify facebook app admin when comments are posted using the social plugin

Can I send notifications to facebook application administrators when comments are posted using the facebook social comments plugin?

The comment plugin is configured as follows:

<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> 

In this example, a very good event subscription works (shows a response message), but is it possible to send notifications to application administrators?

Your help will be appreciated.

+6
source share
1 answer

I installed a simple PHP script to email me whenever a comment is posted. PHP looks like this:

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

and this JavaScript passes the URL of the comment page to a 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 additional addresses if I need to.

+5
source

Source: https://habr.com/ru/post/911781/


All Articles