WeChat enterprise account development: Enable callback mode and callback

Source: Internet
Author: User

Enterprise ID development: Enable callback mode and callback
How can I enable the callback mode for enterprise ID development? Simply log on to the PC Edition, click the Application Center, select the desired application, and then click "enable callback mode?

It seems not that simple !!



We can see that there are only three URL, Token, and EncodingAESKey parameters at the core. Can these parameters be entered at will?
Can I enter 1 URL as needed?
 
It is certain that it cannot be entered at will. If you don't believe it, try it. Because Click OK to send information to this URL. Therefore, this URL must be accessible from the Internet.
In addition, the background must process the sent information. For example, if the URL is http://www.hao123.com/, it can be stored on the Internet, but it will be displayed when you click "save:
Echostr Verification Failed. Please check whether the decryption is correct and output the plaintext echostr


Can I enter 2Token as needed?
Yes. I have not found any special requirements.


Can I enter 3EncodingAESKey as needed?
It cannot be entered at will. It must be a combination of numbers and letters and must contain 43 characters. We recommend that you use a random generation.
 


We know that configuring a URL that can be accessed from the Internet at the URL does not guarantee that it is saved successfully. What should we do in the background?
For example, I configure http: //.../TestWeixin. ashx
The encryption and decryption functions to be called in the background.
The background code of TestWeixin. ashx is:

Public void ProcessRequest (HttpContext context) {if (context. request. httpMethod. toLower () = "post") {} else // call {Valid () ;}} private void Valid () {string msg_signature = HttpContext when you click Save. current. request. queryString ["msg_signature"]; string timestamp = HttpContext. current. request. queryString ["timestamp"]; string nonce = HttpContext. current. request. queryString ["nonce"]; string decryptEc HoString = ""; // The parsed plaintext string echoStr = HttpContext. current. request. queryString ["echoStr"]; bool isok = CheckSignature (msg_signature, timestamp, nonce, echoStr, ref decryptEchoString); if (isok) {if (! String. isNullOrEmpty (decryptEchoString) {HttpContext. current. response. write (decryptEchoString); HttpContext. current. response. end () ;}} public bool CheckSignature (string signature, string timestamp, string nonce, string echostr, ref string retEchostr) {string token = "token "; // configure token string corpId = "corpId"; // corpid, string encodingAESKey = "encodingAESKey"; // configure tokenencodingAESKey WXBizMs GCrypt wxcpt = new WXBizMsgCrypt (token, encodingAESKey, corpId); // call the provided function int result = wxcpt. verifyURL (signature, timestamp, nonce, echostr, ref retEchostr); // call the provided function if (result! = 0) {LogInfo. error ("ERR: VerifyURL fail, ret:" + result); return false;} return true; // ret = 0 indicates the verification is successful, and retEchostr indicates the plaintext, you need to use retEchostr as the return parameter of the get request and return it to the enterprise number.}



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.