使用说明:
参照:https://www.58dir.cn/11592.html 获取你的:corpid、corpsecret、agentid,
替换代码中的****,然后丢在你主题的functions.php中即可!
具体代码:
add_action('comment_post', 'comment_WeChat_notify');
function comment_WeChat_notify($comment_id){
$comment = get_comment($comment_id);
$parent_id = $comment->comment_parent ? $comment->comment_parent : '';
$spam_confirmed = $comment->comment_approved;
function send_post($url, $post_data) {
$postdata = http_build_query($post_data);
$options = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type:application/x-www-form-urlencoded',
'content' => $postdata,
'timeout' => 15 * 60 // 超时时间(单位:s)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return $result;
}
$url = get_option('home');
$description = "<div class='gray'>有人在《".get_the_title($comment->comment_post_ID)."》给您留言啦!<br>".trim($comment->comment_author)."说:".trim($comment->comment_content)."</div>"; //消息内容,有能力的可自行修改,支持html!
$post_data = array(
'corpid'=>'****', //换成你自己的
'corpsecret'=>'***',//换成你自己的
'agentid'=>'***',//换成你自己的
'title'=>'有人在你的博客上评论留言啦!', //消息标题
'description'=>$description,
'url'=>$url
);
send_post('https://api.htm.fun/api/Wechat/text_card/',$post_data);
}
1、升级本站永久VIP,仅需【88】元即可升级 ! ! ! (升级后永久享受整站资源全部免费下载)
2、站内下载币均可通过签到等任务进行免费兑换。
3、站内资源均来源于网络公开发表文件或网友投稿发布,如侵犯您的权益,请联系管理员处理。
4、本站所分享的源码、模板、软件工具等其他资源,都不包含技术服务,请大家谅解!
5、所有资源均收集于互联网仅供学习、参考和研究,请理解这个概念,所以不能保证每个细节都符合你的需求,也可能存在未知的BUG与瑕疵,因本站资源均为可复制品,所以不支持任何理由的退款兑现(特殊情况可退积分),请熟知后再支付下载!
五八弟源码下载 » WordPress评论微信提醒!从此不会漏掉任何一条评论!
常见问题FAQ
- 2020年12月29日Hi,初次和大家见面了,请多关照!