public function sendMSG(){
$access_token=$this->getAccessToken();
$date = date("Y年m月d日 H:i:s",time());
$arr=array(
'touser'=>"LiuQi01",
"msgtype"=> "textcard",
"agentid"=>1000004,
"textcard"=>[
"title"=>"消息通知",
"description"=>"<div class=\"gray\">$date</div> <div class=\"normal\">消息提醒</div>",
"url" => "https://crmxc.booseng.com/hYSCkWNrzE.php",
"btntxt"=>"更多"
],
);
$arr=json_encode($arr,JSON_UNESCAPED_UNICODE);
$url="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=".$access_token;
$res=$this->curl_post($url, $arr);
return $res;
}
public function getAccessToken(){
$corpid = "ww2a0a63a6b12ff555";
$corpsecret = "ey7tdsr1BxgjTtqWeFMsmEDADZPBMZM7tFxpMyLKU5Y";
$ret = $this->curl_post("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid&corpsecret=$corpsecret");
$retarr = json_decode($ret,true);
return $retarr['access_token'];
}
public function curl_post($url , $data=array()){
$ch = curl_init();
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_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}