This article details the certification for public platform development & quot; become a developer & quot ;.. Net code. if you are interested, refer to this article to explain how to authenticate the public platform development as a developer. net code parsing. if you are interested, refer
. Net is used to authenticate public service platform development and become a developer. the specific content is as follows:
These codes are used once for authentication and will not be used in the future:
Const string Token = "XXXXX"; // your token protected void Page_Load (object sender, EventArgs e) {string postStr = ""; if (Request. httpMethod. toLower () = "post") {System. IO. stream s = System. web. httpContext. current. request. inputStream; byte [] B = new byte [s. length]; s. read (B, 0, (int) s. length); postStr = System. text. encoding. UTF8.GetString (B); if (! String. isNullOrEmpty (postStr) {// ResponseMsg (postStr); Response. write (ResponseMsg (postStr); Response. end () ;}// WriteLog ("postStr:" + postStr) ;}else {Valid ();}}////// Verify the signature ////// * Sort the token, timestamp, and nonce parameters in lexicographic order. // * Splice the three parameter strings into one string for sha1 encryption. // * After the developer obtains the encryption string can be compared with signature, identifies the Request source. ///
Private bool CheckSignature () {string signature = Request. queryString ["signature"]. toString (); string timestamp = Request. queryString ["timestamp"]. toString (); string nonce = Request. queryString ["nonce"]. toString (); string [] ArrTmp = {Token, timestamp, nonce}; Array. sort (ArrTmp); // Sort string tmpStr = string in alphabetical order. join ("", ArrTmp); tmpStr = FormsAuthentication. hashPasswordForStoringInConfigFile (tmpStr , "SHA1"); tmpStr = tmpStr. toLower (); if (tmpStr = signature) {return true;} else {return false ;}}. private void Valid () {string echoStr = Request. queryString ["echoStr"]. toString (); if (CheckSignature () {if (! String. IsNullOrEmpty (echoStr) {Response. Write (echoStr); Response. End ();}}}////// Write logs (for tracking )///Private void WriteLog (string strMemo) {string filename = Server. MapPath ("/logs/log.txt"); if (! Directory. exists (Server. mapPath ("// logs //") Directory. createDirectory ("// logs //"); StreamWriter sr = null; try {if (! File. exists (filename) {sr = File. createText (filename);} else {sr = File. appendText (filename);} sr. writeLine (strMemo);} catch {} finally {if (sr! = Null) sr. Close ();}}
The above is all the content of this article. I hope it will help you learn and support PHP.
The above is a detailed description of the public platform development certification to become the details of developer. Net code parsing. For more details, please follow other articles related to php Chinese network!