5步实现WordPress有新评论微信提醒站长

May平常要工作外,常需要利用自己的业余时间来打理自己的WordPress博客,如果长时间工作忙而不怎么看博客or网站建设,有新评论的时候不能很及时回复到大家。目前,微信是May很喜欢的一款沟通工具,要是当有新评论能及时通过微信通知May,这样May就能随时了解博客评论动态。于是度娘一下,很快就找到了答案。

目前最方便的就是使用Server酱。Server酱,英文名:ServerChan,是一个牛人开发的从服务器推报警和日志到手机的工具,Server酱扮演的是WordPress服务器与微信之间通信的中间人角色。文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

以下步骤是经May亲自测试成功的,请大家放心使用哦。文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

Step 1. 授权GitHub账号登录Server酱

在浏览器地址栏输入:http://sc.ftqq.com - 登入 - 使用GitHub账号登入Server酱(如果没有GitHub账号则点击“Create an account”创建一个账号) - 允许GitHub账号登录Server酱文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

注册ServerChan文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

Step 2. 绑定微信推送

二维码有效期只有2秒,拿出手机,微信扫一扫二维码即完成绑定。ServerChan绑定微信文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

Step 3. 获取SCKEY

点击“发送消息”,获取自己的SCKEY。复制下来,备用哦。文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

获取SCKEY文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

Step 4. 代码配置

下面代码中的“你的SCKEY”更改为你在将Step 3复制下来的SCKEY哦;文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

然后将代码配置到WordPress的function.php中文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

//评论微信推送  
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('http://sc.ftqq.com/'.$key.'.send', false, $context);  
}  
add_action('comment_post', 'sc_send', 19, 2);

(代码来源于网络,不清楚是哪位大师留下的代码,如果有知道,请告知May)文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

Step 5. 验证

完成上面的4步操作后,当博客有新评论时,微信绑定的Server酱公众号-方糖,就会发送消息提醒哦。文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

微信发送新评论提醒文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

 文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

哈哈,成功啦~~~文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

大家不妨试一试?如有任何问题,请在下方留言。文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

 文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

 文章源自MAY的SEO博客-https://may90.com/building/serverchan.html 文章源自MAY的SEO博客-https://may90.com/building/serverchan.html

  • 我的微信
  • 扫一扫微信,添加好友
  • weinxin
  • 我的微信公众号
  • 关注公众号,了解最新动态
  • weinxin
  • 本文由 发表于 2018年10月8日
  • 转载请务必保留本文链接:https://may90.com/building/serverchan.html
WordPress SEO这些常规设置不容忽视 SEO建站

WordPress SEO这些常规设置不容忽视

如果您想在搜索引擎结果页中获得良好的排名,则需要认真对待SEO优化。如果您选择了WordPress建站,需要恭喜您的是:您已经节省了很多建站时间,更重要的是WordPress对SEO友好。如果您想进一...
评论  2  访客  0  作者  2
    • MAY的SEO博客

      很好

    发表评论

    匿名网友 填写信息

    :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

    确定