java micro-channel public number of development steps

Recent requests for the development of a micro-channel public number, because the page templates provide micro-channel can not meet our needs, so developers need to adopt model micro-channel public number. I also just record what this development steps for future needs again. Proceed as follows:

1, you first need to apply for a micro-channel public number. Specifically, how to apply, please log number micro-channel public platform application can be.

2, prepare an external network mapping tool. Because developers need to fill in a server mode, the address of the server must be "http" at the beginning or the "https", which requires the url address must be accessible to the public Internet. In addition, the port only supports 80 ports.

     About external network mapping tool has many, here we recommend a useful tool --ngrok. (There may be a wall, you can not be used)

     Method: (1) ngrok download executable program file downloaded is a ngrok.exe.

              cmd to open a command window win, and then enter the file directory ngrok.exe file is located; then enter ngrok 8080, press Enter; [8080 note here is the port configuration of your local TOMCAT]

     Methods: (2) Since ngrok is a foreign server, speed is very slow. Further ngrok generated URL is a random number. It is recommended that another tool --tunnel, the deployment in the country, the Tunnel is based ngrok network services .

              cmd to open a command window win, and then enter the file directory ngrok.cfg file is located; then enter the command:ngrok -config ngrok.cfg -subdomain ××× 8080, press Enter; [8080 TOMCAT port; ××× is your custom domain name prefix]

              For example: ngrok -config ngrok.cfg -subdomain ex 8080, after then mapped into the transport URL is: http://jyj.tunnel.qydev.com

      Methods: (3) to https://www.ngrok.cc/user.html this URL to register an account opened tunnel → → select a free server. (Disadvantage is that the speed is not very fast)

image.png

          Methods: (4) there is a natapp is also good, you can log natapp official website, register an account and then open a free tunnel. Natapp is the way I used.

3, javaEE to build a back-end platform, I use here is Springboot framework. Build on Springboot project can refer to my previous article 51cto blog.

4, javaEE get back desirable to provide a method as a way to enter the inlet end of the micro channel public services number.

For example: HTTP: // xxxx / VX / index

(1) backend architecture as follows:

clipboard.png

(2) define the inlet WeiXincontroller class method: This method is used to authenticate the server and the server is linked micro channel successfully. ( Custom class and a CheckUtil.java SecuritySHA1Utils class code file download:. HTTPS: //pan.baidu.com/s/1_CHTrKoBhH1MDUAFXAs5ZQ )

clipboard.png

5, log number micro-channel public platform to enter developer mode, configure the server address url. url is the path that method 3 steps provided.

For starters, it can be used in plain text mode.

clipboard.png

6, after the information configured, click submit, if prompted to submit successful, it means that the local server and server to establish a micro-channel link, we can call some method to the micro-channel interface provided by the.

7, then it can be developed. According to the public micro-channel number in the developer documentation prompts.

Here we need to define another of the same name (same entrance and get the method name) of the post method:

clipboard.png

Guess you like

Origin blog.51cto.com/13082457/2438153