PHP micro-Letter Development Template Message reply

Source: Internet
Author: User
This article is mainly for you to introduce the simple implementation of PHP development template message reply information, interested in the small partners can refer to

On the public platform, there is a template message reply interface: Can be used to respond to specific messages-----such as the user after the order, reply to the user your order is being processed ... For example, the following picture:

After the user has done some action, the service number can return a specific message----this is the template message.

To implement a reply to a template message, your public number must be certified, and if it is a personal subscription number, it is not supported for the time being. But it does not affect the test-----You can use the test public number:

When using the test number, the configuration of the interface information is not spoken, you can refer to my previous blog.

After using the dimension code login test number, you need to use your number to pay attention to this test number, or not see the reply of the template message.

When I was doing the test, I used a plugin from chrome: Postman. The plug-in can specify various HTTP requests such as sending Get,post, which is powerful and useful when testing interfaces.

1, send GET request to get test number access_token: Your test number appid&secret= your test number Appsecret

2. Set up industry:

Send a POST request with the parameters:

Request: You just got the Access_token


{     "industry_id1": "1",     "Industry_id2": "2"    }

The parameters of 1 and 2 indicate the industry, the specific industry can refer to the document:

Send a POST request specifically you can use curl to send, should not be difficult. I use postman to send. A successful JSON message is returned after the send is complete, and then the next step can be made

3, get the template ID: This piece you can customize, you can also use some built-in.

For example, use a custom template ID: There's a "new test template" in your test number.

Once submitted, you can see that your template ID appears:

Then another way to generate the template ID is to send a POST request (either curl or send with postman)

Request: Https://


{      "Template_id_short": "TM00015"    }

The TM00015 is the ID of the built-in template, which you can find in the graphical interface of (authentication required)

4, after obtaining the template ID, refresh your test number page, you can see the appearance of:

5. With the template_id_short you get, send a POST request to get a msgid:

Request: Https:// your Access_token

The data sent:

{      "Touser": "Test number of the followers of OpenID",      "template_id": "You just got the template id",      "url": "Followers click on your template message when jumping link",            "data": {          "First": {            "value": "Congratulations on your successful purchase!" ",            " color ":" #173177 "          },          " Ordermoneysum ": {            " value ":" 666 ",            " color ":" #173177 "          },          " Orderproductname ": {            " value ":" Mens Dress ",            " color ":" #173177 "          },          " Remark ": {            " value ":" Welcome to buy again! " ",            " color ":" #173177 "}}    }

Color indicates the colors of the fields in your template

The official document does not explain the above parameters, I wrote the above in Chinese the meaning of each field, it should be noted that Touser is not the focus on the client's "number", but as the number

After you send the parameters by post, you get a msgid:

When you get this successful response, at the same time, your test public number should also return a template message to you (followers)

This article just describes how to make a template message, if you want to use the project, also please self-browsing developer documentation, combined with micro-payment, event push and other advanced features to do together.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.