使用Server酱实现WordPress评论微信通知
大家都知道WordPress可以使用邮件推送,但是可能有的朋友可能不是随时看打开自己的邮箱查看,因而介绍一个新的推送方式,使用Server酱来给博主推送评论信息,操作步骤也是非常简单,感兴趣的朋友快来试试吧
操作步骤
Server酱官网:sct.ftqq.com ,直接扫描微信即可,登陆后直接复制SendKey
保存

将下面的代码放入functions.php
中,把自己SendKey
复制到代码中
//博客评论消息微信推送
function sc_send($comment_id)
{
$text = '博客上有一条新的评论';
$comment = get_comment($comment_id);
$desp = $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);
return $result = file_get_contents('https://sctapi.ftqq.com/'.$key.'.send', false, $context);
}
add_action('comment_post', 'sc_send', 19, 2);
效果演示
本站发出一条评论测试

Server酱的消息推送马上就看到了,消息时间都是22:50


感兴趣的朋友可以试一下,需要说明的是免费用户每天最多可发送5条通知,如果想要无限发送通知需要订阅Server酱的会员
版权声明:
文章标题:使用Server酱实现WordPress评论微信通知
文章作者:HONG
文章链接:https://www.hongnote.cn/120.html
CC共享协议许可协议:BY-NC-SA 4.0
文章标题:使用Server酱实现WordPress评论微信通知
文章作者:HONG
文章链接:https://www.hongnote.cn/120.html
CC共享协议许可协议:BY-NC-SA 4.0
THE END
二维码
打赏


文章目录
关闭
共有 0 条评论