Wordpress 评论时微信推送提醒

获取 Server酱SendKey

微信扫码登录获取 Server酱 Turbo 版官网

图片[1]-Wordpress 评论时微信推送提醒-软件开发技术分享

微复制以下 SendKey 备用

图片[2]-Wordpress 评论时微信推送提醒-软件开发技术分享

在wordpress主题 function.phpfunctions.php 文件尾部添加以下代码

//评论微信推送
function sc_send($comment_id){
$text = '自定义标题文字';
$comment = get_comment($comment_id);
$desp = $comment->comment_content;
$key = '你的Server酱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);
//评论微信推送
function sc_send($comment_id){  
    $text = '自定义标题文字';
    $comment = get_comment($comment_id);
    $desp = $comment->comment_content;
    $key = '你的Server酱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);
//评论微信推送 function sc_send($comment_id){ $text = '自定义标题文字'; $comment = get_comment($comment_id); $desp = $comment->comment_content; $key = '你的Server酱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);

选择推送通道

点击https://sct.ftqq.com/forward 查看可选通道,博主用的是 iOS Bark 版通道

图片[3]-Wordpress 评论时微信推送提醒-软件开发技术分享

推送事例

图片[4]-Wordpress 评论时微信推送提醒-软件开发技术分享

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
Suffer all the pain can destroy a person, but it also can kill the pain.
一切痛苦能够毁灭人,然而受苦的人也能把痛苦消灭