纯代码实现WordPress/Emlog评论微信提醒功能[Server酱]

Server酱

英文名「ServerChan」,是一款「程序员」和「服务器」之间的通信软件。

说人话?就是从服务器推报警和日志到手机的工具

工作图

图片[1]-纯代码实现WordPress/Emlog评论微信提醒功能[Server酱]-轻刻年轮

记磊博客

准备工作

1.首先你要准备一个用GitHub账号来登入网站,链接:https://github.com/
2.进入Server酱使用GitHub账号一键登录
3.选微信登录-绑定微信号
4.选发送消息-在线测试下,收到即成功,下面就需要你的SCKEY

WordPress使用方法(代码)

将获取的 SCKEY,替换代码中的“你的 SCKEY”,添加到 function.php文件保存即可
代码;

//评论微信推送
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);

emlog设置方法(需要插件)

图片[2]-纯代码实现WordPress/Emlog评论微信提醒功能[Server酱]-轻刻年轮
下载插件安装即可,手动安装路径应该都知道,最后扩展功能找到评论微信提醒 把“你的 SCKEY”,设置保存即可,

效果图

图片[3]-纯代码实现WordPress/Emlog评论微信提醒功能[Server酱]-轻刻年轮

插件下载链接

emlog
————
[secret key=”emlog”]链接: https://pan.baidu.com/s/1i8RVmorfFWuW0ldvqP9AFg 密码: mysb[/secret]

购买后下载不了源码或源码功能失效请联系小编,确认后可立即退款,请勿无理投诉
© 版权声明
THE END
喜欢就支持一下吧
点赞1赞赏 分享
评论 共21条

请登录后发表评论