PHP企業(yè)微信的機(jī)器人函數(shù)
發(fā)布時(shí)間:2023-01-11 點(diǎn)擊數(shù):12061
function posturl($data){
$data_content = '{"msgtype":"text","text":{"content":"'.$data.'"}';// 直接發(fā)送消息
$url = "機(jī)器人webhook地址";
$headerArray =array("Content-type:application/json;charset='utf-8'","Accept:application/json");
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_content);
curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return json_decode($output,true);}