<meta charset="utf-8"> <?PHP function getcfg(){ $cfg['getAccessTokenUrl']='http://xxxx/send_msg.php'; $cfg['appid']='xxx'; $cfg['appsecret']='xxx'; return $cfg; } $cfg = getcfg(); $access_token_url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$cfg['appid'].'&secret='.$cfg['appsecret']; $at = file_get_contents($access_token_url); $at = json_decode($at,true); $post_msg_url = 'https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token='.$at['access_token']; $post_msg_data = array( 'touser'=>array('xxx','xxx'), 'msgtype'=>'text', 'text'=>array('content'=>'hello from boxer') ); $json_msg_data = json_encode($post_msg_data); // $ch = curl_init(); //设置超时 curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_URL, $post_msg_url); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt($ch, CURLOPT_HEADER, 0); //设置header curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //要求结果为字符串且输出到屏幕上 curl_setopt($ch, CURLOPT_POST, 1); //post提交方式 curl_setopt($ch, CURLOPT_POSTFIELDS, urldecode($json_msg_data)); //运行curl,结果以jason形式返回 $data = curl_exec($ch); curl_close($ch); print_r($data);exit; //\ ?>
预览发送内容
<?PHP session_start(); error_reporting(0);?> <meta charset="utf-8"> <?PHP function getcfg(){ $cfg['getAccessTokenUrl']='http://xxxxxxxx/send_msg.php'; $cfg['appid']='xxxxxx'; $cfg['appsecret']='xxxxx'; return $cfg; } $cfg = getcfg(); $access_token_url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$cfg['appid'].'&secret='.$cfg['appsecret']; $at = file_get_contents($access_token_url); $at = json_decode($at,true); //$post_msg_url = 'https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token='.$at['access_token']; $post_msg_url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token='.$at['access_token']; $post_msg_data = array( 'touser'=>'xx-xx-xxxxxxx', 'msgtype'=>'text', 'text'=>array('content'=>'hello from 发士大夫<a href="http://xxxxxx.com">s是s发</a>') ); $json_msg_data = json_encode($post_msg_data); $json_msg_data = '{"touser":"oEXy-xxx-xxx","msgtype":"text","text":{"content":"您的优惠券即将过期请尽快使用 \n <a href=\"http://xxxx.com\">点击查看我的优惠券</a>"}}'; //echo urldecode($json_msg_data);exit; // $ch = curl_init(); //设置超时 curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_URL, $post_msg_url); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt($ch, CURLOPT_HEADER, 0); //设置header curl_setopt($ch, CURLOPT_HTTPHEADER, array("content-type: application/x-www-form-urlencoded; charset=UTF-8")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //要求结果为字符串且输出到屏幕上 curl_setopt($ch, CURLOPT_POST, 1); //post提交方式 curl_setopt($ch, CURLOPT_POSTFIELDS, ($json_msg_data)); //运行curl,结果以jason形式返回 $data = curl_exec($ch); curl_close($ch); print_r($data);exit; //\ ?>
相关推荐
python使用win32接口自动化操作微信发送消息
java 微信发送消息 http://ip地址/ajie-wechat/checkWechat
基于Swoole的微信发送模板消息队列服务项目模板
微信发送消息格式
java开发微信发送消息,内含微信发送消息的请求数据模型。
delphi 登陆微信账号之后发送微信消息给用户。值得学习。功能详细,自己慢慢研究把。
泛微OA会议申请,企业微信发送消息通知参会人员
C#编写的企业微信发送文本消息,发送图片给指定人员;包括Get、Post方式发送获取数据
微信的官方文档,接收和发送消息处理示例
php文件,2个函数,亲测可用微信发送消息PHP源代码
以订单推送为例,主要为大家详细介绍了java实现微信公众号发送模版消息,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
基于Python实现企业微信机器人发送消息(文本类型消息、Markdown 类型消息、图文类型消息),实现自动化,多样化。
自己写的一个小demo,VBS之“指定微信好友发送消息
.net 版本 发送微信模板模板消息给关注公众号的用户,支持单个发送,同时也支持批量发送,经过测试完全可以使用。
微信企业微信短信邮件qq发送消息
填入appid,secrect,openid,模板id即可使用。 下载请到 http://download.csdn.net/detail/bob548811888/9510584
java调用企业微信接口发送消息所需依赖 文章链接:https://blog.csdn.net/zxl782340680/article/details/79876502
将企业微信群机器人发送 文字、图片、MarkDown、文件消息 封装成了一个工具类: 1.可以用于自建的群,即不是使用企业微信api创建的群,不需要群id; 2.主要使用 okhttp3 调用机器人api和上传文件到临时素材api; 3.有...
利用PHP实现发送微信模板消息,可自行扩展