C # Development Series-1.0 enable developer mode,
1.0 enable developer Mode
① Fill in the Server Configuration:
To enable the development mode, you must first become a developer. You can select only one edit mode and development mode (go to the public platform> development => basic configuration) to view the following interface:
Click modify configuration. The following page is displayed:
Enter the server address (URL), Token, and EncodingAESKey. The URL is the interface URL used by the developer to receive messages and events. The Token can be entered by the developer as needed to generate a signature (the Token will be compared with the Token contained in the interface URL to verify security ). The EncodingAESKey is manually entered or randomly generated by the developer and will be used as the accesskey for message body encryption and decryption.
In addition, developers can select the plaintext mode, compatibility mode, and security mode for message encryption and decryption. The Mode Selection and server configuration will take effect immediately after submission. Please be careful when entering and selecting. The default encryption/Decryption mode is plain text. To select the compatible mode and security mode, you must configure the relevant encryption/decryption code in advance, for more information, see the message body signature and encryption/Decryption section (public message encryption/Decryption development document ).
② Verify the validity of the server address:
After the developer submits the information, the server sends a GET request to the server Address URL filled in. The GET request carries four parameters.
The developer verifies the request by verifying signature (The following is a verification method ). If you confirm that the GET request is from the server, return the content of the echostr parameter as it is, and the access takes effect. If the access succeeds, the access fails (note: the server only supports port 80 ).
The specific implementation code is as follows:
1 public void InterfaceTest () 2 {3 string token = "token entered during configuration"; 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}