WeChat public platform development template message

高洛峰
Release: 2017-02-28 09:48:51
Original
1741 people have browsed it

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:

  1. Apply for template message permission

  2. Develop template message SDK

  3. 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.

WeChat public platform development template message

Click to apply

WeChat public platform development template message

When applying, just select 2 industries related to yourself.

WeChat public platform development template message

After the application is submitted and approved, you can see the template message list in the template library

WeChat public platform development template message

Enter the template message you want to use Template, click Add

WeChat public platform development template message

#After adding, it will be stored in "My Template Library"

WeChat public platform development template message

View template For details, you can see the template id and each content parameter name

WeChat public platform development template message

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

WeChat public platform development template message

WeChat public platform development template message


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.

WeChat public platform development template message


According to the above conditions, we construct the message body as follows

WeChat public platform development template message

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))));
Copy after login

The effect is as follows:

WeChat public platform development template message


For more articles related to WeChat public platform development template news, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!