当使用社交插件发布评论时,通知Facebook应用程式管理员 [英] Notify facebook application admin when comments are posted using social plugin
问题描述
评论插件是这样设置的:可以通过Facebook的应用程序管理员发送通知,当评论是
发布使用Facebook社会评论插件?
Is it possible to send notification to facebook application admins when comments are posted using facebook social comments plugin?
<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?
您的帮助将不胜感激。
推荐答案
我设置了一个简单的PHP脚本,以便在发布评论时发送电子邮件。 PHP是这样的:
I set up a simple PHP script to email me whenever a comment is posted. The PHP is like this:
<?php
mail('me@example.com','facebook_notification.php',
'Comment activity on http://example.com'.$_GET['path']);
,此JavaScript将注释页面的URL传递给PHP脚本:
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.
这篇关于当使用社交插件发布评论时,通知Facebook应用程式管理员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!