Use java to develop public accounts: Test public accounts and build a local test environment (1). java Public Accounts
As the saying goes, to do a good job, you must first sharpen it. To develop a public account, you must have a public account for testing and a development environment for code adjustment.
Test public account
The public account contains the subscription number, service number, and enterprise number. You can apply for the subscription number only when registering the public account. The service number and enterprise number must be qualified by the enterprise. The public number development mentioned here refers to the subscription number and service number.
In addition, unauthenticated personal subscription numbers have some interfaces that do not have permissions, and currently personal subscription numbers do not support authentication. That is to say, personal subscription numbers cannot call some advanced permission interfaces, is a list of permissions that an unauthenticated individual subscribe has. Interface permissions such as generating QR code, webpage authorization, custom menu, and payment are not available.
After talking about it for a long time, what should I do if I do not have the qualification of an enterprise and want to develop advanced interfaces.
Public platform provides test public account, login address: http://mp.weixin.qq.com/debug/cgi-bin/sandbox? T = sandbox/login. You only need to go to this page, click "Log on", scan the Code with your own client, and authorize logon to obtain your own test public account. The test public number has almost all interfaces. If there is no public number available for development at ordinary times, you can use the public number for the test.
Local test environment
Debugging is a major pain point in the development of public accounts. Each time a function is implemented, it must be deployed on a public network server. Although there are various free cloud platforms available for deployment, however, the mode can only rely on log output, and it has not been modified-> deployment-> View logs. Such an operation process is a waste of time and time is life, isn't it a waste of life. Is there a way to deploy and debug locally?
Of course, because every time a command is sent to the Public Account, the server where the public account is located must interact with your server over the network. Therefore, ensure that your server can access the Internet, you only need to map your local IP address to an Internet address for local debugging of the public account. There are a lot of software that provides such functions, such as peanut shells, but they are charged. Here we will introduce a free software, ngrok, which may require FQ for access. You can register an account based on the required local version, windows or linux. After the account is successfully registered, you will receive a free authorization code, which will be used when ngrok is started for the first time.
For example, if I download windows, download and decompress the file, find the decompressed directory, and double-click ngrok.exe. When I start it for the first time, enter the following command:
Ngrok-authtoken authorization code 80
Then, double-click ngrok.exe, and enter the command to map the local machine to the Internet, and map the web Service under the local port 8080 to the Internet port 80. The command is as follows:
ngrok http 8080
The startup interface is as follows:
The red part is the ing internet address. Now, access to this address is the access to the local port 8080. However, in the free version of ngrok, the generated Internet ing addresses are random and will be different for each restart, but it does not matter because ngrok will not be closed once every day during the START process. After each start, go to the test Public Account Management page and reconfigure it.
As of now, ngrok is available. That is to say, although the ngrok server has been blocked by the wall, the public account server can be accessed. This will not prevent us from implementing local adjustment. Just download and register ngrok. You need FQ.
There are some ngrok servers in China, but they have not been tried. If you are interested, you can search for them by yourself. Of course, if you have the ability, you can build an ngrok platform by yourself. ngrok is implemented in the go language and the code is open source to github.