WeChat public platform development template message
In this WeChat public platform development tutorial, we will introduce how to develop template messages, that is, how to use the program to send template messages.
This article is divided into the following three parts:
Apply for template message permission
Develop template message SDK
Construct the template message body and send it
1. Apply for template message permission
Application for template message requires an account number WeChat payment permission has been activated.
In the backend of the WeChat public platform, enter "Function->Add Function Plug-in->Template Message" to apply for a template message.
Click to apply
When applying, just select 2 industries related to yourself.
After the application is submitted and approved, you can see the template message list in the template library
Enter the template message you want to use Template, click Add
#After adding, it will be stored in "My Template Library"
View template For details, you can see the template id and each content parameter name
The content structure of different template messages is different. These IDs and field names will be used in the program.
2. Development of Template Message SDK
The template message is defined as follows:
The template message is also sent using access token as authorization.
We are based on the WeChat public platform advanced SDK with slight modifications. The SDK implementation of the template message is as follows
3. Construct the template message body
Let’s take a horizontal version of a purchase success notification in the news product industry as an example. Its content is as follows.
According to the above conditions, we construct the message body as follows
Call SDK to send, the code is as follows
require_once('weixin.class.php'); $weixin = new class_weixin(); var_dump($weixin->send_template_message(urldecode(json_encode($template))));
The effect is as follows:
For more articles related to WeChat public platform development template news, please pay attention to the PHP Chinese website!

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Chinese version
Chinese version, very easy to use
