微信发送模版消息,PHP代码简单案例
function http_request($url,$data=array()){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// POST数据
curl_setopt($ch, CURLOPT_POST, 1);
// 把post的变量加上
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
function send_wx_msg(){
$access_token=$this->http_request("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $this->APPID . "&secret=" . $this->APPSECRET);
$access_token=json_decode($json_token,true);
//获得access_token
$this->access_token=$access_token['access_token'];
//echo $this->access_token;exit;
//模板消息
$template=array(
'touser'=>'o8BlDv8Wy6t99QnbcOgmYgUxj///openid',
'template_id'=>"zgnQX1A-0jXK-ghw0d3xjxHIKdKpEQZjpUSkDTNZwOA",
'url'=>"http://neweb.top",
'topcolor'=>"#7B68EE",
'data'=>array(
'first'=>array('value'=>urlencode("恭喜你成功升级为钻石会员。"),'color'=>"#FF0000"),
'account'=>array('value'=>urlencode("戴先生"),'color'=>'#FF0000'),
'time'=>array('value'=>urlencode(date("Y-m-d H:i:s")),'color'=>'#FF0000'),
'type'=>array('value'=>urlencode('免费升级'),'color'=>'#FF0000'),
'remark'=>array('value'=>urlencode('恭喜你升级为钻石会员,点击查看会员特权。'),'color'=>'#FF0000'),
));
$json_template=json_encode($template);
$url="https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$this->access_token;
$res=$this->http_request($url,urldecode($json_template));
//if ($res['errcode']==0) echo '发送成功';
}
微信发送模版消息,PHP代码简单案例的更多相关文章
- 微信小程序中发送模版消息注意事项
在微信小程序中发送模版消息 参考微信公众平台Api文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/notice.html#模版消息管理 此参考地址 ...
- 微信小程序 发送模版消息
微信小程序开发之发送模板消息 1,小程序wxml页面form表单添加 report-submit="true" <form bindsubmit="sub" ...
- 使用WxPusher给自己的个人微信发送提醒消息(WxPusher微信推送服务)
1.背景 我们很多时候,我们在服务器上运行软件,发生一些业务异常,需要给我们发送一个及时的提醒,或者是使用一些耗时软件,比如抢车票,抢课,刷优惠券当任务运行成功以后,也需要及时的发送消息给自己 ,告诉 ...
- uniapp 微信发送订阅消息
这篇主要针对小程序进行演示,既然是发送消息,那么就有三个问题.发送什么内容,给谁发送,怎么发送!往下一条一条解决. 发送什么消息内容 - 通过微信公众号平台 选择对应的消息模板 选择以后在我的模板里面 ...
- 跨进程发送消息数据(发送WM_COPYDATA消息,够简单的)
1 //1.发送窗体 2 procedure TForm2.Button1Click(Sender: TObject); 3 var 4 h: HWND; 5 Size: Integer; 6 Cop ...
- 微信小程序开发 给微信发送模板消息提示openId无效
参数我都给好了,也是post的raw方式发送请求, openId是绝对没有问题的. 但就是一直报如下错误 {"errcode":40003,"errmsg":& ...
- C# 微信公众平台开发(4)-- 模版消息
微信公众平台开发 --发送模版消息 发送模版消息是微信服务号给某个用户发送模版消息,类似于APP的推送通知: 1.添加模版消息 在页面的左上 有一个添加功能插件的 按钮,如题 添加完成后,我们就可以在 ...
- golang/beego 微信模版消息
// GO的微信SDK我用的是这个:https://github.com/silenceper/wechat // 发送模版消息 // UserNickName,UserMobile是发起预约的人的昵 ...
- 微信小程序-发送模板消息
1 添加一个小程序的消息模板,获取到模板id,存储到数据库中,方便以后修改调用 2. https://developers.weixin.qq.com/miniprogram/dev/api-back ...
随机推荐
- ATL向控件添加私有属性-成员变量
https://msdn.microsoft.com/zh-cn/library/cc451389(v=vs.71).aspx ------------------------------------ ...
- 【285】ArcPy 暗色窗体设置
预览图 设置如下 Default:
- CrackMe的简单破解
[CrackMe的简单破解] 对于以下这样的输入账号和密码的窗口,我们可以猜测该程序使用最简单的机制实现,即用strmp来比较用户输入的密码和原始密码匹配.所以为了破解该程序,可以通过bp strmp ...
- BeanUtils简单应用
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http:// ...
- struts2 框架的基本使用
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http:// ...
- “Device eth0 has different MAC address than expected, ignoring.”问题
配IP后进行激活的时候提示如下错误:("Device eth0 has different MAC address than expected, ignoring.") 百度了下, ...
- 使用Python定时执行一任务,自动登录某web系统,生成报表,然后发送邮件给指定人员
一.项目需求 每周从A系统生成一张Excel报表,发送此报表给指定人员,相关人员依据此报表去完成后续的工作. 项目限制: 1.无法通过EDI系统交互的方式从后台读取数据 2.由于公司网络环境限制,不能 ...
- solidity错误处理
官方文档: https://solidity.readthedocs.io/en/develop/control-structures.html#error-handling-assert-requi ...
- 在Global.asax文件的Application_BeginRequest中获取request请求内容
protected void Application_BeginRequest(object sender, EventArgs e) { try { string isLogRequest = Sy ...
- servlet-向页面输出中文出现乱码处理方式
package cn.lijun .content; import java.io.IOException;import java.io.PrintWriter; import javax.servl ...