Home  >  Article  >  WeChat Applet  >  C# WeChat development method to enable developer mode

C# WeChat development method to enable developer mode

高洛峰
高洛峰Original
2017-03-13 13:20:031835browse

This article mainly introduces the steps and methods of enabling developer mode in WeChat development. It has certain reference value. Let’s take a look at it with the editor

Enable developer mode

##①Fill in the server configuration

To enable 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) and you can see the following interface:

Click to modify Configuration, the following interface will appear: C# WeChat development method to enable developer mode

Fill in the server address (URL), Token and EncodingAESKey, where the URL is the C# WeChat development method to enable developer mode interface used by developers to receive WeChat messages and events

URL. Token can be filled in by developers and used to generate signatures (the Token will be compared with the Token contained in the interface URL to verify 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 encryption and decryption is plain text mode. To select compatibility mode and security mode, you need to configure the relevant encryption and decryption codes in advance. For details, please refer to the document on message body signature and encryption and decryption (WeChat official account message encryption and decryption development document).

②Verify the validity of the server address

After the developer 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 become a developer successfully, otherwise the access will fail (C# WeChat development method to enable developer modeNote: WeChat server only supports port 80

).

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

public void InterfaceTest()
{
  string token = "配置时填写的token";
  string echoString = HttpContext.Current.Request.QueryString["echoStr"];
  string signature = HttpContext.Current.Request.QueryString["signature"];
  string timestamp = HttpContext.Current.Request.QueryString["timestamp"];
  string nonce = HttpContext.Current.Request.QueryString["nonce"];
  if (!string.IsNullOrEmpty(echoString))
  {
    HttpContext.Current.Response.Write(echoString);
    HttpContext.Current.Response.End();
  }
}


The above is the detailed content of C# WeChat development method to enable developer mode. 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