How to develop template messages on Wechat Public platform
This article is about how Wechat public platform develops template messages. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Apply for template message permission
The application of template message requires that the account has been activated with the permission of WeChat Pay.
In the backend of Wechat public platform, enter "Features"-> "add feature plug-ins"-> "template message" to apply for a template message.
Click to apply
When applying, you can choose 2 related industries.
After the application is submitted and approved, you can see a list of template messages in the template library.
Enter the template you want to use and click add
Add it and store it in my template Library.
Check the details of the template, you can see the id of the template and the parameter names of each content.
Different template messages have different content structures. These id and field names will be used in the program.
2. Develop template message SDK
Template messages are defined as follows:
Template messages are also sent using access token as authorization.
Basically, we only need to modify the advanced SDK on Wechat public platform. The SDK implementation of the template message is as follows
Third, construct the template message body
Let's take the horizontal version of a successful purchase notification in the messaging industry as an example, and its content is as follows.
According to the above conditions, we construct the message body as follows
Call SDK to send, with the following code
Require_once ('weixin.class.php'); $weixin = new class_weixin (); var_dump ($weixin- > send_template_message (urldecode (json_encode ($template)
The results are as follows:
Thank you for reading! This is the end of the article on "how to develop templates on Wechat Public platform". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!