杂谈漫话 |JiuGoe

嗨,欢迎来访~
  • {{ item.name }}
  • 开通并使用上它,只需要一分钟:
  • 然后在function.php中添加以下代码即可:
  • 首 页
  • 生活杂谈
  • 设计笔札
  • 奇技淫巧
  • 文章归档
  • 豆瓣书影
  • 左邻右舍
  • 关 于

分享 – 微信接收评论推送

  • JiuGoe
  • 2018-05-14
  • 1

虽然网站没啥人来,我还是想着「快速接收评论推送」这事,万一哪天就有人来访留个脚丫子呢?之前用HyperComments可以手机下载App接受推送,觉得多一个App有点堵。功夫不负有心人,我找到了「Server酱」—— 具有「微信推送评论」功能。唯一的要求就是有一个GitHub账号,以前我就有GitHub账号,所以这事不难。

开通并使用上它,只需要一分钟:

  • 登入:用GitHub账号登入网站,就能获得一个SCKEY(在「发送消息」页面)
  • 绑定:点击「微信推送」,扫码关注同时即可完成绑定
  • 发消息:往 http://sc.ftqq.com/SCKEY.send 发GET请求,就可以在微信里收到消息啦

然后在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('http://sc.ftqq.com/'.$key.'.send', false, $context);  
}
add_action('comment_post', 'sc_send', 19, 2);

Danile_Lxp
05-14

©2015-2023 杂谈漫话小站 All Rights Reserved
Modified By JiuGoe With 粤ICP备15050919号|WordPress & Wing