<?
/*
Plugin Name: QQ小助手
Plugin URI: http://www.zwbeta.com/website/design/Comment-to-QQ.html
Description: 评论、留言消息通知到QQ上,<a href="http://www.zwbeta.com/website/design/Comment-to-QQ.html" target="_blank">如何使用QQ小助手</a>.
Version: 0.1
Author: 笨小孩
Author URI: http://www.zwbeta.com
*/
function comment_qq($comment_id) {
  $admin_email = get_bloginfo ('admin_email'); // $admin_email 可改為你指定的 e-mail.
  $comment = get_comment($comment_id);  //取得留言内容
  $comment_author_email = trim($comment->comment_author_email);  //取得管理员邮箱
  $parent_id = $comment->comment_parent ? $comment->comment_parent : '';
  $spam_confirmed = $comment->comment_approved;   
  if(($admin_email != $comment_author_email ) && ($spam_confirmed != 'spam') )
   {
    $msg ='【'. trim($comment->comment_author) .'】在' . get_the_title($comment->comment_post_ID) . '评论:'.trim($comment->comment_content);
	
	$qq="344506806";//你的QQ
	$qqrobot="412975332";//机器人QQ
		
	$imid="xxx";//服务ID
	$impass="xxx";//服务密码
		
	$opts = array('http' => array( 'method' => 'POST', 'content' => 'api=SendMessage'.'&sIMId='.$qq.'&sRId='.$qqrobot.'&sMsg='.$msg));  
	$context = stream_context_create($opts);  
	$Data = file_get_contents("http://im.jecat.cn/api/?sSId=".$imid."&sSPwd=".$impass, false, $context);
   }  
}
add_action('comment_post', 'comment_qq');
?>
