Home  >  Article  >  WeChat Applet  >  Developer mode of WeChat development

Developer mode of WeChat development

Y2J
Y2JOriginal
2017-05-09 09:38:413405browse

1.0 Enable developer mode

①Fill in the server configuration

To enable the development mode, you need to become a developer first, and you can only choose one of the editing mode and the development mode (enter the WeChat public platform =>Development =>Basic configuration)You can see the following interface:

##Click to modify the configuration, the following interface will appear:

##Fill in the server address (URL), Token and EncodingAESKey, where the URL is the

interface URL used by developers to receive WeChat messages and events . The token can be filled in by the developer arbitrarily and used to generate a signature (the token will be compared with the token contained in the interface URL to verify the security). EncodingAESKey is manually filled in by the developer or randomly generated, and will be used as the message body encryption and decryption key.

At the same time, developers can choose the message encryption and decryption methods: plain text mode, compatibility mode and

security mode. The mode selection and server configuration will take effect immediately after submission. Developers are advised to fill in and select carefully. The default state of the encryption and decryption method is plaintext mode. Selecting compatibility mode and security mode requires configuring the relevant encryption and decryption codes in advance. For details, please refer to the document on message body signature and encryption and decryption (WeChat public account message encryption and decryption development documentation).

②Verify the validity of the server address

Development After the user submits the information, the WeChat server will send a GET request to the filled-in server address URL. The GET request carries four parameters.

Developers verify the request by checking the signature (the verification method is below). If it is confirmed that this GET request comes from the WeChat server, please return the echostr parameter content as it is, then the access will take effect and you will become a developer successfully, otherwise the access will fail (

Note: WeChat server only supports port 80).

Use GET request with the above parameters to request the server, the specific implementation code:

 1 public void InterfaceTest() 2 { 3   string token = "配置时填写的token"; 4  5   string echoString = HttpContext.Current.Request.QueryString["echoStr"]; 6   string signature = HttpContext.Current.Request.QueryString["signature"]; 7   string timestamp = HttpContext.Current.Request.QueryString["timestamp"]; 8   string nonce = HttpContext.Current.Request.QueryString["nonce"]; 9 10   if (!string.IsNullOrEmpty(echoString))11   {12     HttpContext.Current.Response.Write(echoString);13     HttpContext.Current.Response.End();14   }15 }
[Related recommendations]

1.

WeChat public account platform source code download

2.

Alizi order system source code free download

The above is the detailed content of Developer mode of WeChat development. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn