Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build Wechat Development Environment

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to build the Wechat development environment, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

At present, mobile development is in a hot trend, and many developers are eager to try. At present, the field of mobile App development is mainly divided into the following types

In my usual work, I have come into contact with Native App development based on Android and Light App development based on Wechat official account. Today, I will lead you to quickly enter the development field of Wechat official account.

I. Construction of Wechat development environment

If you want to do good work, you must first sharpen its tools. To develop an official Wechat account, you must first prepare two essential things:

1. There should be an official account for testing.

2. The development environment used to modulate the code.

1.1. Register the official test account.

Wechat official account is divided into service number, Subscription account, enterprise account, Subscription account can apply personally, service number and enterprise account must have enterprise qualification.

When we talk about the development of Wechat official account, we refer to Subscription account and the service number.

This is the official explanation of the difference between Subscription account and the server.

Service number: mainly tends to service interaction (function similar to 1231515 114, bank, provides binding information, service interaction), can send 4 messages per month; service number is suitable for people: media, enterprise, government or other organizations.

Subscription account: mainly tends to convey information to users. (the function is similar to newspapers and magazines, providing users with news or entertainment), one message can be sent in groups every day; Subscription account is suitable for people: individuals, media, enterprises, governments or other organizations.

Personal Subscription account has some APIs that do not have permissions, that is, personal Subscription account cannot call some advanced permission APIs. The following figure shows a list of permissions that my personal Subscription account has, as shown below:

While some advanced interfaces, such as generating QR codes, web page authorization, custom menus, and interface permissions such as WeChat Pay, individual Subscription account does not have the permission to call them. For example, personal Subscription account cannot call those interfaces framed in red above.

Fortunately, the Wechat public platform provides a test public account. The registered address of the test official account is http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login. Just go to this page, click to log in, scan the code with your own Wechat client, and authorize login to get your own test official account. The test official account has almost all the interfaces, so when you usually learn the development of Wechat official account, you can register a test official account, and then use this test official account for development. Cut the crap and sign up for a test official account first.

Visit http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login and register for a test official account.

The steps to register the test official account are shown in the following figure:

Scan the above QR code with Wechat to log in. After the login is successful, you can see the information of the test official account assigned by Tencent, as shown below:

The API permissions of the test official account are as follows:

As you can see, the test official account has most of the permission to call the interface, so it is possible to use the test official account to learn Wechat development.

1.2. build a local debugging environment for Wechat

The biggest pain in developing an application based on Wechat official account is the debugging problem. Each time a function is implemented, it needs to be deployed to a public network server for testing, because every time Wechat users make a request to the official account, Wechat server will first receive the user's request, and then forward it to our server, that is to say, Wechat server is to interact with our server. So we have to make sure that our server can be accessed outside the network, and this practice of deploying to a public network server for testing is a nightmare for us developers. So we have to think of a way to deploy and debug the code locally, and to do this, then the problem we need to solve is to map the deployment server of the internal network to the external network, so that the Wechat server can be accessed normally. Fortunately, with the help of third-party software Ngrok, we can do this. Ngrok is a free software Ngrok, after using Ngrok, we can achieve intranet penetration, that is to say, we can map the server of the intranet to the extranet for others to access, which is very fast and helpful for us to debug Wechat code in the local development environment and to show users some things, because we can directly use computers in our own intranet as servers.

The better website to provide Ngrok service in China is: http://natapp.cn/, as shown below:

Download the ngrok client from the http://natapp.cn/ website, as shown in the following figure:

After the download is completed, you get a compressed package, and after unzipping the compressed package, you get a folder containing the files shown in the following figure:

Open a CMD command line window, go to the ngrok_windows directory, and enter the following command:

Ngrok-config ngrok.cfg-subdomain xdp 8080, as shown in the following figure:

Xdp is a domain name defined by myself, and 8080 is the running port of the local server. After executing the above command, we can map the local 127.0.0.1 8080 server to the public network, as shown in the following figure:

At this point, users in the public network can directly use the domain name http://xdp.ngrok.natapp.cn to access the 127.0.0.1 8080 server in my private network, as shown below:

After using ngrok, we can use the intranet server as a public network server. The speed of access is still within an acceptable range, so far ngrok is available, Wechat official account server is accessible, so it does not prevent us from doing local mode. At this point, our Wechat local debugging and development environment is set up.

These are all the contents of the article "how to build the Wechat Development Environment". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report