


Teach you how to use public account template messages in mini programs (with detailed ideas)
This article brings you some related issues about WeChat mini programs. It mainly introduces how to use official account template messages in mini programs. Let’s take a look at them together. I hope it will be helpful to everyone.
Cause
There is a reservation function in a small program I made recently, which successfully reminds the user that the reservation is successful and notifies the person who made the reservation
Process
Because in the mini program, the first idea is to use "subscribe message"
A problem occurs at this time: the template usage of the subscription message is affected by the service category of the mini program. The current service category can only use one-time subscription, and user authorization is required every time a message is sent
This is not the desired result! ! ! [Recommendation: 小program video tutorial]
So I looked for alternatives. Emails were too boring and text messages did not keep pace with the times. The official account had a template message, but it still didn’t work. If there is no corresponding public account registration, what should I use? Baidu also posted a blog asking
what can be used instead of subscribing to messages?
I sincerely thank all the enthusiastic friends for their answers
In the end I chose to use the template message of the public account
It will be easier to register the public account The official account is associated with the mini program.
The second problem occurs during the next process: when logging in to the mini program and replacing the session with code, the
unionID## cannot be obtained.
# I learned from the Internet that the reason was that there was no association configuration on the WeChat open platform. In order to get confirmation, I posted another blog post about not being able to get the unionID when logging in. Thank you again
Through these two blogs, I came up with two ways to complete the function, and tested them both successfully. Next, post the method ideas
Thoughts
Use unionID- to ensure that the public account and the mini program are successfully associated with each other
- Configure the association of the open platform
The mini program customer is from Macau, so
one time
authentication is required when registering the open platform for the customer The fee is
99 US dollars. The US dollar has increased in value and is now equivalent to more than
700in RMB.
Customer: Tencent is awesome! ! ! - After the association is completed, the mini program user can obtain the
unionID
when logging in, and save it
- At this time, it was impossible to obtain the
openID
of the public account directly through
unionID, so I used a troublesome method (I don’t know any other good method yet)
- First obtain the fan list of the public account (please refer to the official development document for how to obtain it), and store the
openID
of each fan user into the data table. At this time, it is impossible to tell which fan is following. If the user has a public account
- , then the next step is to obtain the corresponding
unionID
through
openIDand then save it to the data of the corresponding fan user . The
unionIDobtained at this time is
the same as the previously savedunionID
. The next step is to compare - unionID
Let’s get the corresponding
openID
The second type is very simple to say, and it is also very simple to do for the backend
Use
- Silent authorization for official account login
General idea:The front end of this project is
uniapp, okay, first use
Probably like this
web-viewto adjust the official authorization interface. Note that it must be silent authorization. ! At this time, you will get the code, and then request the backend through this code... Then you can get the openID... With the openID, you can send the template message...
The above is the detailed content of Teach you how to use public account template messages in mini programs (with detailed ideas). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Linux new version
SublimeText3 Linux latest version