我在粉丝页面上有一个包含评论插件的iFrame
应用程序。是否有一种方法让我或任何管理员在每次有人添加评论时收到通知或电子邮件?
我在粉丝页面上有一个包含评论插件的iFrame
应用程序。是否有一种方法让我或任何管理员在每次有人添加评论时收到通知或电子邮件?
comment.create
事件并以任何你喜欢的方式向管理员发送通知,一旦评论被创建。Facebook本身不提供这样的功能。<script type="text/javascript">
FB.subscribe('comment.create', function(response){
// Here you need to do a call to some service/script/application
// to notify your administrator about new comment.
// I'll use jQuery ajax to call server-side script to illustrate the flow
$.post('//hostnamne/path/to/script', {
"action": "comment created",
"url_of_page_comment_leaved_on": response.href,
"id_of_comment_object": response.commentID
});
});
</script>
在位于 http(s?)://hostname/path/to/script
的脚本中,您可以向管理员发送通知,具体方法可能因您所需而异。例如,如果您想发送电子邮件,可以使用类似以下 PHP 示例的代码(尽管这只是一个流程示例,您不应该使用真实代码):
<?
$admin_email = 'root@localhost';
$commentID = $_REQUEST['id_of_comment_object'];
$page_href = $_REQUEST['url_of_page_comment_leaved_on'];
$message = "comment #{$commentID} was leaved on page {$page_href}";
mail($admin_email, "You have a new comment", $message);
?>
comment.remove
事件,其流程类似...