PHP 微信公众号 群发文本消息
2018-01-30 16:57
337 查看
//公众号 群发文本消息 //http://api.lialiu.com/test/qunfa public function qunfa(){ //https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=ACCESS_TOKEN //引入微信工具类 import("ORG.Util.Gongzhonghao"); //实例化 $wx = new weixin; #获取token $token=$wx->get_token(); #文本消息 $msgArray= array( "touser"=> array( "", ), "msgtype"=>"text", "text"=>array( "content"=>urlencode("感谢关注赏金联盟!") ) ); $json=urldecode(json_encode($msgArray)); //var_dump($json);exit; #群发 文本消息 $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); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($ch); curl_close($ch); if($res['errcode']==0){ echo "推送成功"; }else{ echo "推送失败!"; } }
使用 urlencode 是为了避免在 json_encode的时候被转码unicode.
追加:今天发现用户收不到群发消息,于是又去查了文档,发现文档上有这么一行小字。这意味着,每月只能群发4条消息。
对于认证服务号虽然开发者使用高级群发接口的每日调用限制为100次,但是用户每月只能接收4条,无论在公众平台网站上,还是使用接口群发,用户每月只能接收4条群发消息,多于4条的群发将对该用户发送失败;
相关文章推荐
- 微信公众号模板消息群发php代码示例
- Python实现的微信公众号群发图片与文本消息功能实例详解
- 利用python 实现微信公众号群发图片与文本消息功能
- 微信公众号开发之文本消息自动回复php代码
- 微信公众号开发之文本消息自动回复,以及系统关注自动回复,php代码
- PHP7.0微信公众平台开发6: 实例三:群发预览消息
- C#实现微信公众号群发消息(解决一天只能发一次的限制)
- php微信公众号模板消息主动推送
- C#实现微信公众号群发消息(突破破解一天只能发一次的限制)
- php实现微信公众号主动推送消息
- php 微信模拟登陆 获取用户列表 群发消息
- .net微信公众号开发——群发消息
- 微信公众号发送文本消息时如何在文本消息中包含超链接
- php微信公众号模板消息主动推送
- C#实现微信公众号群发消息(解决一天只能发一次的限制)实例分享
- C#微信公众号全攻略(5)--群发消息时的openid对应的用户是谁呢
- 微信公众号开发--群发图文消息,消息体包含图片地址