一: 企业微信官方文档:https://work.weixin.qq.com/api/doc/90000/90136/91770
data数据:
$url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?'; //创建群机器人自动分配的url地址 $data = array( 'msgtype'=> 'text', 'text' =>array( 'content' => "this is message", //'mentioned_list' => ['@all'], //开启@全体群成员 ) );
//调用发送方法:
post_message($url, $data);
/* * 企业微信机器人群发消息 * */ function post_message($url, $data) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-type:application/json', )); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); //设置请求方式 curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));//设置提交的字符串 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); return $result; }