Home >WeChat Applet >WeChat Development >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
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.
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
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!