


A brief analysis of how to dynamically create mini program codes
This 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 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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

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!
