<?php function request_by_curl($remote_server, $post_string) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $remote_server); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json;charset=utf-8']); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 线下环境不用开启curl证书验证, 未调通情况可尝试添加该代码 // curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); // curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); $data = curl_exec($ch); // print_r($data);die; curl_close($ch); return $data; } // 机器人hook地址,access_token需要更换成自己的token哦! $webhook = "https://open.feishu.cn/open-apis/bot/v2/hook/730e55fe-fa0c-4ac0-a049-d6ccc"; $message = "告警头像更换完成~"; $data = [ 'msg_type' => 'text', 'content' => ['text' => $message], ]; $data_string = json_encode($data); $result = request_by_curl($webhook, $data_string); echo $result;
标签:string,text,机器人,接口,result,php,data From: https://www.cnblogs.com/hualingyun/p/17172245.html