1 //群发消息接口 2 public function sendMessage(){ 3 $access_token = $this->getWxAccessToken(); //1、获取access_token 4 $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token='.$access_token; 5 /*{ "touser":"OPENID", "text":{ "content":"CONTENT" }, "msgtype":"text" } { "touser":"OPENID", "mpnews":{ "media_id":"123dsdajkasd231jhksad" }, "msgtype":"mpnews" } */ 6 $arr = array( 7 'touser'=>'oBdTesvQ3Q7m_fKQe1312312313', 8 'text'=>array('content'=>urlencode('hello,这个是群发测试!')), 9 'msgtype'=>'text' 10 ); //2、准备数据 11 /*$arr2 = array( 'touser'=>'oBdTesvQ3Q7m_fKQejI6XQ9XCk2o', 'mpnews'=>array('media_id'=>'123dsdajkasd231jhksad'), 'msgtype'=>'mpnews' );*/ 12 $postJson = urldecode(json_encode($arr)); //3、转成json数据 13 $res = $this->http_curl($url,'post','json',$postJson); //4、调用发送数据,打印返回结果 14 var_dump($res); 15 } 16 17 备注: 微信开发文档 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1481187827_i0l21