search
HomeWeChat AppletWeChat DevelopmentWeChat public platform development template message

WeChat public platform development template message

Feb 28, 2017 am 09:48 AM
Micro-channel public platform

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))));

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!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

mPDF

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

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

Atom editor mac version download

The most popular open source editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use