改用Server酱Turbo版推送WordPress评论
5666
这几天发现博客有评论Server酱不推送微信消息了,上Server酱官网才发现旧版推送已经下线了,新的Turbo版启用企业微信应用消息通道,看了下新旧版本调用函数代码大同小异,新版修改如下,欢迎食用:
- //评论微信推送
- function wpso_wechet_comment_notify($comment_id) {
- $text = get_bloginfo('name'). '上有新的评论';
- $comment = get_comment($comment_id);
- $desp = $comment->comment_author.' 同学在文章《'.get_the_title($comment->comment_post_ID).'》中给您的留言为:'.$comment->comment_content;
- $key = '你的SendKey';
- $postdata = http_build_query( array( 'text' => $text, 'desp' => $desp ));
- $opts = array(
- http' => array(
- 'method' => 'POST',
- 'header' => 'Content-type: application/x-www-form-urlencoded',
- 'content' => $postdata
- )
- );
- $context = stream_context_create($opts);
- $admin_email = get_bloginfo ('admin_email');
- $comment_author_email = trim($comment->comment_author_email);
- if($admin_email!=$comment_author_email){
- return $result = file_get_contents('https://sctapi.ftqq.com/'.$key.'.send', false, $context);
- }
- }
- add_action('comment_post', 'wpso_wechet_comment_notify', 19, 2);
消息通道设置请移步Server酱Turbo版官网按说明操作即可,修改第6行SendKey为你所获取的值。
转载自:https://www.yxt521.com/network/1557.html
本文网址:https://www.zztuku.com/index.php/detail-8963.html
站长图库 - 改用Server酱Turbo版推送WordPress评论
申明:如有侵犯,请 联系我们 删除。
您还没有登录,请 登录 后发表评论!
提示:请勿发布广告垃圾评论,否则封号处理!!