微信发送模版消息,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 ...
随机推荐
- PHP 环境安装
官方 http://www.php.net/ http://php.net/manual/zh/install.php http://php.net/manual/zh/index.php 下载也就是 ...
- 用sysbench压测MySQL,通过orzdba监控MySQL
1.1 安装sysbench wget https://codeload.github.com/akopytov/sysbench/zip/0.5 unzip 0.5 cd sysbench-0.5/ ...
- LibEvent代码阅读--多缓冲区和零拷贝技术
http://blog.chinaunix.net/uid-20937170-id-4827550.html
- Winform Datagridview 单元格html格式化支持富文本
Winform Datagridview 单元格html格式化支持富文本 示例: 源码:https://github.com/OceanAirdrop/DataGridViewHTMLCell 参考: ...
- .NET 调用c++库注意事项
很久没有更新了,主要还是因为自己懒吧,希望从今天开始坚持至少一周写一篇文章. 调用函数库是正常的,调用完成后,在使用EF进行数据更新时,将发生如下异常信息,而且几乎必现. 行库遇到了错误.此错误的地址 ...
- Tags and Layers
[Tags and Layers] 1.tags and layers 配置面板."Edit" -> "Project Settings" -> & ...
- js,javascript生成 UUID的四种方法
全局唯一标识符(GUID,Globally Unique Identifier)也称作 UUID(Universally Unique IDentifier) . GUID是一种由算法生成的二进制长度 ...
- apt-get update 时的问题 W:Failed to fetch gzip:/var/lib/apt/lists/partial...解决办法
http://askubuntu.com/questions/149454/upgrade-from-11-04-to-11-10-getting-wfailed-to-fetch-gzip 这个问题 ...
- matplotlib的颜色和控制条
为了方便记忆,收藏备用 一 linestyle '-' solid line style '--' dashed line style '-.' dash-dot line style ':' dot ...
- xgboost dmatrix中的 weight的重要性
https://stackoverflow.com/questions/35983565/how-is-the-parameter-weight-dmatrix-used-in-the-gradien ...