我是从@小猫 那里得知第三方微信推送消息这个服务的,她的主题已经集成了。确实很不错,有了这个基本可以放弃邮箱推送了,所以这次做发自来水,帮助推广。
ASky 1.5会集成,这几天就放包——我不会告诉你我已经在用了的。
「Server酱」,英文名「ServerChan」,是一款「程序员」和「服务器」之间的通信软件。
说人话?就是从服务器推报警和日志到手机的工具。
开通并使用上它,只需要一分钟:
1、登入:用GitHub账号登入网站,就能获得一个SCKEY(在「发送消息」页面)
2、绑定:点击「微信推送」,扫码关注同时即可完成绑定
3、发消息:往 http://sc.ftqq.com/SCKEY.send 发GET请求,就可以在微信里收到消息啦
那么,怎么在wordpress里使用:在你完成了登入(用GitHub账号)获得一个SCKEY,完成了绑定(关注微信公众号)以后,在你的主题目录的function.php里,找个不起眼的地方,写下以下代码:
//微信评论推送
function sc_send( $comment_id)
{
$text = '起来!有大佬评论了!' ;
$comment =get_comment($comment_id);
$comment_text= $comment ->comment_content;
$author = $comment ->comment_author;
$comment_title = get_the_title($comment->comment_post_ID);
$comment_link = get_comment_link($comment_id);
$desp = '大佬【'.$author.'】在《'.$comment_title.'》里给你做了批示:“'.$comment_text.'。”---你要看么?'.$comment_link;
$key = '这里填入你的SCKEY'
//akina_option('akina_server_key')这里是ASKy主题获取主题设置里的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);
然后你就可以愉快地接收微信消息了,放弃邮箱吧。亲测相当稳定,如图: