Loading... **添加到function.php,保存修改相关参数即可:** ```php /** * PHP发送Json对象数据 * * @param $url 请求url * @param $jsonStr 发送的json字符串 * @return array */ function http_post_json($url, $jsonStr) { $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($jsonStr) ) ); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return array($httpCode, $response); } //评论微信推送 function sc_send($comment_id) { $text = '您的博客上有一条新的评论'; $comment = get_comment($comment_id); $desp = $comment->comment_content; //$key = '你的SCKEY'; $url = "http://wxpusher.zjiecode.com/api/send/message"; $jsonStr = json_encode(array("appToken"=>"AT_*******","summary"=>"有人给你评论啦!!","content"=>$desp,"contentType"=>"1","uids"=>["UID_*************"],"url"=>"https://rr.rw/1.ooo")); list($returnCode, $returnContent) = http_post_json($url, $jsonStr); //$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); //var_dump ($jsonStr); //var_dump($httpCode); //var_dump ($returnContent); ``` 最后修改:2020 年 07 月 08 日 05 : 53 PM © 允许规范转载 赞赏 如果觉得我的文章对你有用,请随意赞赏 ×Close 赞赏作者 扫一扫支付 支付宝支付 微信支付