一、说明
1、可以在前一篇博客基础上添加一个方法即可,方法代码下面讲解
二、实现流程
1、看开发手册:
https://mp./wiki?t=resource/res_main&id=mp1481187827_i0l21
2、代码实现:
//群发接口function sendMsgAll(){//1、获取全局access_token$access_token = $this->getWxAccessToken();$url = "https://api./cgi-bin/message/mass/preview?access_token=".$access_token;//2、组装群发接口数据array//单文本群发$array = array('touser' => '',//微信用户的openid'text' =>array('content' => 'imooc',),//文本内容'msgtype' =>'text',//消息类型);//3、将array->json$postJson = json_encode($array);//4、调用curl$res = $this->http_curl($url,'post','json',$postJson);}
3、补充说明:
‘touser’ => ’ ‘,//微信用户的openid就是