search
HomeWeChat AppletMini Program DevelopmentTeach 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

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!

Statement
This article is reproduced at:learnku. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

DVWA

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

SublimeText3 English version

Recommended: Win version, supports code prompts!

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version