Nowadays, everyone shops on mobile phones for convenience, so most of the traffic is transferred to mobile terminals. In order to attract traffic to merchants, Taobao customers also set their sights on the mobile terminal, starting with WeChat mini program docking. The editor below will talk about how to connect Taobao customers to WeChat mini programs. I hope it will help everyone. How do Taobao customers connect to WeChat mini programs?
First of all, you must have your own WeChat mini program, and you must also have a Taobao alliance account. Things to note when registering WeChat Mini Programs are as follows:
Currently, WeChat Mini Programs are only open to enterprises and some related units. Individuals are temporarily unable to apply for Mini Programs. When applying, select a registered account on the WeChat official account login interface, and then select the mini program.
Then fill in the registration information for the Taobao mini program. I won’t go into details about filling in the basic information here. The mini program needs to be verified. There are two verification methods, one is to transfer funds from a corporate account, and the other is to conduct WeChat authentication.
The first method does not cost any money. You only need to transfer a few cents to your Tencent account. The second type of WeChat authentication requires a 300 yuan authentication fee.
After the registration of Taobao mini program is completed, you can develop the Taobao mini program. Generally, the mode of using WeChat mini program to promote Taobao is the shopping mall model, which is similar to many coupon websites. Same. You can publish Taobao baby information and order links on it. The steps for Taobao to connect to WeChat mini programs are as follows:
1. Taobao environment preparation
1. Set up HTTPS and WSS environments
Use NginX for proxy forwarding.
2. Define the front-end and back-end communication JSON protocol
Among them, token is used to verify the legitimacy of the message source, fd is the current socket connection resource ID, and from is the other party's socket connection resource ID. , cmd is used to define the current operation.
2. Construction of Taobao chat system
1. Server
Uses TP5 and swoole extensions, and creates a new socket module to handle socket requests .
The directory structure is as follows:
It is divided into server.php and client.php. The server runs in cli form. For specific code, please refer to the SSL sample in the woole source code package.
Run the command as follows, first switch to the public directory of the server program code:
php index.php socket/server/index
The client is actually a web For websocket on the client, examples are also provided in the source code package for your reference.
2. Mini program
We need to simply encapsulate the socket interface to handle operations such as successful connection, sending messages, and automatic reconnection if the connection fails. As a Taobao customer, how can you quickly create a WeChat mini program?
1. Step one: Apply for registration. At present, the mini program is only open to enterprises and some related units. Individuals are temporarily unable to apply for the mini program. When applying, select a registered account on the WeChat official account login interface, and then select the mini program.
2. Step 2: Fill in the registration information. I won’t go into details about filling in the basic information here. The mini program needs to be verified. There are two verification methods, one is to transfer funds from a corporate account, and the other is to conduct WeChat authentication. The first one costs nothing and only requires a few cents to be transferred to a Tencent account. The second one requires a 300 yuan authentication fee for WeChat authentication.
3. Step 3: You can search for codes shared by others, and then play some simple small programs, and gradually become more advanced.