ThinkPHP3.2.3实现推送微信模板消息,已封装成类库。
微信公众平台的“模板消息功能”允许服务号运营者事先设计好信息框架,如果用户与微信服务号产生数据交换,替代模板消息中的数据,即可直接生成信息给用户。如下图
下面我结合THINKPHP3.2.3介绍下微信消息模板推送的实现。
一、申请权限(注意:只有开通支付功能的公众账号才可以申请模板消息推送接口)
微信限制最多只能选择8个模板,应该也够用了。选中模板后就可以看到模板ID、标题等,这里已购买成功为列,查看详情时:
二、引入类库
下载我已经封装好的微信模板推送类库WxTemple.class..php,修改配置信息。需要修改的字段有apiKey、apiSecret、templateId,这三个字段可以从微信公众平台里查看到。
三、使用方法
在控制器里调用类库include COMMON_PATH.'Lib/WxTemple.class..php';<br>
<br>
$send = array(<br>
'openid' => '微信授权后获取的_id',<br>
'url' => '点击后跳转的地址',<br>
'title' => '通知内容',<br>
'info' => '商品名',<br>
'points' => '价格',<br>
'remark' => '备注信息'<br>
);<br>
$sendMes = new sendMessage ();<br>
$sendMes->sendTempleMessage ( $send );
了解详情或下载类库请访问http://www.gouguoyin.cn/php/115.html
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
