


How to build a local test environment for java WeChat public account development
Mar 14, 2017 pm 01:59 PMThis article mainly introduces the development of Java WeChat public account. The main content includes testing the public account and building a local test environment. Friends in need can refer to it
As the saying goes, if you want to do your job well, you must first do it well. Sharpen your tools. To develop a WeChat public account, two things are indispensable, that is, a public account for testing and a development environment for debugging the code.
Test public account
WeChat public account has subscription account, service account, and enterprise account. When registering, you see this information. Only subscription account can be applied for personally. , service accounts and enterprise accounts must have enterprise qualifications. The WeChat public account development mentioned here refers to subscription accounts and service accounts.
In addition, some interfaces of unauthenticated personal subscription accounts do not have permissions, and currently personal subscription accounts no longer support WeChat authentication, that is It is said that personal subscription accounts cannot call some advanced permission interfaces. The picture below is a list of permissions that an uncertified personal subscription account has, such as generating QR codes, web page authorization, custom menu, and WeChat payment. Interface permissions are not available.
After talking for a long time, what should I do if I don’t have enterprise qualifications and want to develop advanced interfaces.
WeChat public platform provides a test public account, the login address is: http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login , you only need to go to this page, click to log in, scan the code with your own WeChat client, and authorize the login, you can get your own test public account. The test official account has almost all interfaces. If there is no available official account for normal development, just use this test official account.
Local test environment
One of the major pains in developing WeChat public accounts is the debugging problem, which needs to be deployed every time a function is implemented To a public network server, although there are currently various free cloud platforms that can be deployed, the debugging basically can only rely on log output, and there is no modification->deployment->view log. This operation process is very time-consuming and time-consuming. It’s life, isn’t this a waste of life? So, is there a way to deploy and debug locally?
Of course, because every time you send an instruction to the official account, the server where the official account is located needs to interact with your server over the network. Therefore, your server must ensure that it can be accessed from the external network, so you only need to You can map the local address to an external network address to realize local debugging of the WeChat official account. There are many softwares that provide such functions, such as Peanut Shell, but they are charged. Here is a free software, ngrok, which may require FQ to access. According to the local version required, windows or linux version, then register an account. After account registration is successful, you will get a free authorization code. This authorization code is used when starting ngrok for the first time. Will be used.
Taking my local area as an example, I downloaded the Windows version. After downloading and decompressing, find the decompression directory, double-click ngrok.exe, and enter the following command when starting it for the first time:
ngrok -authtoken Authorization code 80
Then start, double-click ngrok.exe, enter the command after startup to map the machine to the external network, and set the local 8080 The web service under the port is mapped to the external network port 80. The command is as follows:
ngrok http 8080
The interface after startup is as follows:
The red part is the mapped external network address. Now accessing this address means accessing the local port 8080. However, for the free version of ngrok, the external network mapping address generated is random and will be different every time it is restarted. However, it is not a big deal because ngrok will basically not shut down during startup once a day. After each startup, go to WeChat to test Official account management page, just reconfigure it.
As of now, ngrok is available, which means that although the ngrok server is blocked, the WeChat public account server is accessible, which does not prevent us from doing things. Locally adjusted. Just download and register ngrok and you need to FQ it.
There are also some ngrok servers in China, but I have not tried them. If you are interested, you can search yourself. Of course, if you have the ability, you can build an ngrok platform yourself. ngrok is implemented in the go language.
The above is using java to develop WeChat public accounts to implement public account testing and local test environment construction. I hope it will be helpful to everyone's learning.
The above is the detailed content of How to build a local test environment for java WeChat public account development. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

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

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)

The settings.json file is located in the user-level or workspace-level path and is used to customize VSCode settings. 1. User-level path: Windows is C:\Users\\AppData\Roaming\Code\User\settings.json, macOS is /Users//Library/ApplicationSupport/Code/User/settings.json, Linux is /home//.config/Code/User/settings.json; 2. Workspace-level path: .vscode/settings in the project root directory

To correctly handle JDBC transactions, you must first turn off the automatic commit mode, then perform multiple operations, and finally commit or rollback according to the results; 1. Call conn.setAutoCommit(false) to start the transaction; 2. Execute multiple SQL operations, such as INSERT and UPDATE; 3. Call conn.commit() if all operations are successful, and call conn.rollback() if an exception occurs to ensure data consistency; at the same time, try-with-resources should be used to manage resources, properly handle exceptions and close connections to avoid connection leakage; in addition, it is recommended to use connection pools and set save points to achieve partial rollback, and keep transactions as short as possible to improve performance.

itertools.combinations is used to generate all non-repetitive combinations (order irrelevant) that selects a specified number of elements from the iterable object. Its usage includes: 1. Select 2 element combinations from the list, such as ('A','B'), ('A','C'), etc., to avoid repeated order; 2. Take 3 character combinations of strings, such as "abc" and "abd", which are suitable for subsequence generation; 3. Find the combinations where the sum of two numbers is equal to the target value, such as 1 5=6, simplify the double loop logic; the difference between combinations and arrangement lies in whether the order is important, combinations regard AB and BA as the same, while permutations are regarded as different;

DependencyInjection(DI)isadesignpatternwhereobjectsreceivedependenciesexternally,promotingloosecouplingandeasiertestingthroughconstructor,setter,orfieldinjection.2.SpringFrameworkusesannotationslike@Component,@Service,and@AutowiredwithJava-basedconfi

fixture is a function used to provide preset environment or data for tests. 1. Use the @pytest.fixture decorator to define fixture; 2. Inject fixture in parameter form in the test function; 3. Execute setup before yield, and then teardown; 4. Control scope through scope parameters, such as function, module, etc.; 5. Place the shared fixture in conftest.py to achieve cross-file sharing, thereby improving the maintainability and reusability of tests.

java.lang.OutOfMemoryError: Javaheapspace indicates insufficient heap memory, and needs to check the processing of large objects, memory leaks and heap settings, and locate and optimize the code through the heap dump analysis tool; 2. Metaspace errors are common in dynamic class generation or hot deployment due to excessive class metadata, and MaxMetaspaceSize should be restricted and class loading should be optimized; 3. Unabletocreatenewnativethread due to exhausting system thread resources, it is necessary to check the number of threads, use thread pools, and adjust the stack size; 4. GCoverheadlimitexceeded means that GC is frequent but has less recycling, and GC logs should be analyzed and optimized.

Use classes in the java.time package to replace the old Date and Calendar classes; 2. Get the current date and time through LocalDate, LocalDateTime and LocalTime; 3. Create a specific date and time using the of() method; 4. Use the plus/minus method to immutably increase and decrease the time; 5. Use ZonedDateTime and ZoneId to process the time zone; 6. Format and parse date strings through DateTimeFormatter; 7. Use Instant to be compatible with the old date types when necessary; date processing in modern Java should give priority to using java.timeAPI, which provides clear, immutable and linear

TheJVMenablesJava’s"writeonce,runanywhere"capabilitybyexecutingbytecodethroughfourmaincomponents:1.TheClassLoaderSubsystemloads,links,andinitializes.classfilesusingbootstrap,extension,andapplicationclassloaders,ensuringsecureandlazyclassloa
