Home > WeChat Applet > Mini Program Development > Teach you how to use public account template messages in mini programs (with detailed ideas)

Teach you how to use public account template messages in mini programs (with detailed ideas)

藏色散人
Release: 2022-11-04 16:53:53
forward
5511 people have browsed it

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 700 in 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 openID and then save it to the data of the corresponding fan user . The unionID obtained at this time is the same as the previously saved unionID

  • . The next step is to compare
  • unionID

    Let’s get the corresponding openID

The fan table here always needs to be updated. I don’t know what to do with this method. It’s always uncomfortable to cause trouble

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
  • ##At this time, you need to know the front-end, or you have a front-end friend who is 100% willing to cooperate with you

General idea:
The front end of this project is
uniapp

, okay, first use
web-view to 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...

Probably like this

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!

source:learnku.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template