PHP micro-channel transmission message template

Business need: the number of users of consumer products after deduction of micro letter template to send message alerts

Business scenario: small business version of the user program sweep the two-dimensional code, after deducting the number of times a user of a product

Due to the small business version of the program and the user program are two separate small version of the client, after deduction of the number of merchants version, version and did not warn the user

Send message template under conditions micro letter as follows:

 Our business logic do not meet these two conditions are issued, because the client when the number of deductions, user version is no reminder, subconsciously think of to write Socket

When businesses deduct version number, version prompts to the user, and then trigger a form to obtain from_id, consulted about a friend, a friend said the entire project if there is only one place that might as well write use Socket polling, so this program PASS.

After thinking for a long time to think of a method, the user enters the two-dimensional version of the code page at the same time trigger to submit the form, get to from_id, stored in the database. From_id taken directly to the database after deducting business version number, then you can send a message template

Before you send a message template, you need to do a few things:

1, to obtain the user's openid

2, in a small background application program template, to obtain the required template for a message issued id

3, get appid and secret applet background. Applet only evidence that AppID, can be " micro-channel public platform  - development settings - Settings" page to get in. (Need has become a developer and account no abnormal state)

4, form submission scenarios, to submit events to bring the  formId ; payment scenario-based payment in the  prepay_id .

5, want to call applet backend API interface, you need to get a small program interface calls globally unique background credentials ( access_token) , it is worth noting that, to get the access_token is expired time .

If you have the above, then congratulations, you can already send micro news letter template, like this

 

 The rest is calling applet backend API, send a message template

How to call refer to the applet official document: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/template-message/templateMessage.send.html

Welcome to communicate a message, please point out the inadequacies of, thanks.

 

Guess you like

Origin www.cnblogs.com/blibli/p/11563579.html