tp3.5 微信公众号群发图文消息

来源:互联网 发布:凯文马丁nba2k隐藏数据 编辑:程序博客网 时间:2024/05/17 04:00
public function qunfa(){//https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=ACCESS_TOKENimport("ORG.Util.Gongzhonghao");$wx = new weixin;#获取token$token=$wx->get_token();#获取素材列表$ch = curl_init();curl_setopt($ch, CURLOPT_URL, "https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=".$token);curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array("type"=>"news","offset"=>0,"count"=>10)));curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);$data = curl_exec($ch);curl_close($ch);if($data){$data=json_decode($data,true);//$data['item'][0]['media_id']#群发 图文消息$ch = curl_init();curl_setopt($ch, CURLOPT_URL, "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=".$token);curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( array("touser"=>array("openid","openid","openid"),"mpnews"=>array("media_id"=>$data['item'][0]['media_id']),"msgtype"=>"mpnews","send_ignore_reprint"=>1) ) );curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);$res = curl_exec($ch);curl_close($ch);var_dump($res);}else{echo "推送失败!";}}

原创粉丝点击