


A brief analysis of how to dynamically create mini program codes
Nov 03, 2021 am 11:09 AMThis article will introduce to you how to dynamically create mini program codes through WeChat mini program cloud development. I hope it will be helpful to you!
1. Foreword
Due to many things at school and work, I have given up "farming" for a long time. During this period of time, I learned a lot and worked on nearly 10 projects, large and small. During this process, I became more and more aware of the importance of recording, so I thought of taking time out of my busy schedule to write a blog and record. Let’s talk about some knowledge points in the development process. It’s a cliché, not only so that I can look back on it next time, but also in the hope that I can help those in need. [Related learning recommendations: Mini Program Development Tutorial]
2. Requirements Analysis
In daily WeChat mini program projects, we often need to use some promotional posters, Invitation posters and other functions, such as a poster to invite friends, allow users to post to friends or forward friend invitations after being generated. At this time, we need to know which users you invited, so that we can easily issue rewards and so on. These are very common requirements. So how to achieve similar needs?
3. Idea Analysis
In fact, the most critical one of these posters is the QR code with parameters (mini program code) recognized by long pressing and scanning the code.
By consulting the WeChat applet development documentation, we can know that in general there are two ways to generate this kind of QR code with parameters (mini program code). When this kind of QR code with parameters is drawn When on the poster, you can use the parameters of this QR code to identify which user generated the poster. When other users scan the code to enter the mini program, the identified ID can be stored in the database to determine who invited the poster. of people.
It’s been too long since I’ve written any code, so it might be a bit cumbersome to say it.
To summarize: To determine whose poster is based on the parameters of the QR code, this parameter must be able to locate the user. Generally speaking, the user's openid can be used as the identification parameter. .
A simple example (cloud development):
Define a collection: user
There are two users
U1
Field name | Value | Description |
---|---|---|
123456789 | You can use the id automatically generated by the cloud database, you don’t need to generate it yourself | |
112233 | It will be included when inserting data, and it is also a system field | |
445566 | Superior openid field |
Value | Description | |
---|---|---|
987654321 | Just use the id automatically generated by the cloud database, you don’t need to generate it yourself | |
556677 | It will be included when inserting data, and it is also a system field | |
112233 | Superior openid field |
Path One: Mini Program Code
WeChat provides us with three ways to dynamically generate mini program code. Here I will only talk about cloud The calling method is developed by traditional servers and can be operated according to the documentation. The principle is roughly the same.1, A interface: wxacode.createQRCode
3, B interface: wxacode.getUnlimited
Make a table to analyze these three interfaces. For a detailed introduction, click on the title Direct access to official documents.Generation quantity limit | Timeliness | Carried parameter length | |
---|---|---|---|
The total number of AC interfaces does not exceed 10W | Long-term | 128 bytes | |
AC interfaces add up to no more than 10W | Long term | 128 bytes | |
Unlimited | Long term | 32 visible characters |
The above is the detailed content of A brief analysis of how to dynamically create mini program codes. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Xianyu WeChat mini program officially launched

Implement card flipping effects in WeChat mini programs

What is the name of Xianyu WeChat applet?

WeChat applet implements image upload function

Implement the drop-down menu effect in WeChat applet

How to use PHP to develop the second-hand transaction function of WeChat applet?

Use WeChat applet to achieve carousel switching effect

Alipay launched the 'Chinese Character Picking-Rare Characters' mini program to collect and supplement the rare character library
