Send template message in WeChat applet
This reference address explains in detail and the steps are also very detailed.
The implementation logic is divided into:
1, obtain access_token
2, send template message (including user's openid, template's template_id, user-triggered form form_id or payment Prepay_id)
Note:
1. The user’s openid is obtained through user authorization
2. The template’s template_id can be viewed from the “Template Message” on the Mini Program public platform
3. The from_id of the form is obtained from report-submit="true" in the form submission event triggered by the user. If the user pays the message, the value can be the prepay_id of the order payment
Error return code notes: errcode:41028, errmsg:"invalid form id hint: [YVJBEA0597ge21]"
There are several situations where this error will be reported:
1. It is found that the value of form_id is "the formId is a mock one", which means that it is not tested on a real machine and needs to be tested on a real machine.
2. The user who triggered the determined event and the user who sent the message are not the same person
3. The prepaid user and the user who sent the message are not the same person
Experience: I found a payment notification in the template message on the WeChat public platform. I thought that the user triggered the payment and could send the payment notification to the merchant. But I kept reporting this error, and later I discovered that WeChat does not allow this.
But it can only send payment notifications, but what’s the use? If you have any good solutions, please leave a message and tell me.
The above is the detailed content of Things to note when sending template messages in WeChat mini programs. For more information, please follow other related articles on the PHP Chinese website!