现已不推荐Server酱,因为限定免费额度为5个太少,更甚的是两条消息后就不工作,于是推荐永久免费的Qmsg酱。

Qmsg酱-免费QQ消息推送机器人 Qmsg酱-免费QQ消息推送机器人 博主原来用的是Server酱的,今天下决心启用Qmsg酱。起因是看到一篇文章Server酱和Qmsg酱两个好用的推送服务。外加Server酱限定免费额度为5个,太少了,更甚的是两条消息后就不工作了。 ... 时间:2021/5/12 分类:WP建站 阅读:5

喜欢玩微信的有钱人仍可选择使用Server酱:

为网站新评论添加微信提醒功能!

网站收到了一条评论,

我是在微信上看到提醒的,

感谢Server酱提供的服务。

服务号【方糖】

消息详情:

后台查看评论:

据IP,是个来自英国的朋友!

注意看留言时间与提醒时间,

在同一分钟内,可见同步之迅速。

赶紧回复:

功能实现思路参考了记磊博客

https://www.ly522.com/1109.html

升级版

UxwuitA8zJdfLon

最近2021新年初,又出了Turbo版本:https://sct.ftqq.com/forward

扩展功能很多,比如企业微信消息通道:

配置方法在https://sct.ftqq.com/登录可见。

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 = '你的KEY(注意:这里KEY与原版不同)';
    $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);

原版升级代码:

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 = '你的SCKEY';
    $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('http://sc.ftqq.com/'.$key.'.send', false, $context);
    }
}
add_action('comment_post', 'wpso_wechet_comment_notify', 19, 2);

Server酱是什么?查看官网回答

http://sc.ftqq.com/3.version

网站评论,微信提醒实现方法如下:

一、登录账号,绑定Wechat

1、登录账号:

首先需要一个 GitHub 账号来登入 Server酱网站

官网免费注册账号:github.com/

2、绑定Wechat:

点击「微信推送」,扫码关注同时即可完成绑定。

二、测试消息,获取SCKEY

1、测试消息

在 sc.ftqq.com/SCKEY.send 发送消息,看是否能在微信里收到;

2、获取SCKEY

注意:Turbo版的key请到https://sct.ftqq.com/获取

复制保存 SCKEY,后面要用。

三、添加代码,保存测试

1、添加代码

将 SCKEY 替换到下方代码中的“你的 SCKEY”,添加到当前主题的 function.php 文件保存,并刷新缓存。

2、消息测试

在网站上留言,看是否能收到消息提醒,若不能则检查代码是否正确插入。

function sc_send($comment_id)
{
    $text = '提醒主人,又有小伙伴来留言了';
    $comment = get_comment($comment_id);
    $desp = $comment->comment_content;
    $key = '你的SCKEY';
    $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);
    return $result = file_get_contents('https://sc.ftqq.com/'.$key.'.send', false, $context);
}
add_action('comment_post', 'sc_send', 19, 2);

据说Server酱还有一些高级玩法

大家可以留言交流一下哦!

最近Server酱采用付费服务(测试号版)

V6WlJKk5wpfaA4g

效果展示:
20200816114159
20200823203457
20200816114321

就是卡片直接显示内容

关于价格:
8Zh6gBcaxmY4qdR

封面图:服务号【方糖】头像


Invitation
QQ Group
1095632335

created:04/01/2020

Welcome to the Group

Use this card to join us and participate in a pleasant discussion together .

Welcome to JISHUSONGSHU Group,wish you a nice day .