WeChat ?? ??? ??? ?????? ?? ??? ????? ??? ?? ??? ? ????. ??? ??? ?? ?? ???? ????? ??? ????. WeChat ??? ?? ?????. ???? ?? ? ???? ??? URL? ?????. URL ????? ???? ???? ?? ??? ? ?? ??? ????. ??? ?? ??? ???? ???????. ??? ???? ??, ??? ??? ?? ?? ????? ? ?? ?? ????.
??? WeChat? ??? ??? ?? ????? WeChat ???? ?? ??? ??? ??? ?? ????. ?? ??? ? ?? ??? "??? ????? ??"???. ??? URL? ???? ???. ? URL? WeChat?? ?? ???? ???? ? ????? WeChat? ? ?? ???? URL? ?? ??? ?????. . ???? ???? ?? ????. ????? ?? ??? ?? ???????.
?? ???? ???? WeChat ??? ???? ??? URL? get ??? ????. ? ??? ?? ??(WeChat ???? ??, ??)? 4?? ????? ?????. ???? ??? ?? ????? ??? timestamp ???? ? nonce ????? ??), timestamp(timestamp), nonce(??? ??), echostr(??? ???) .?? ??? ?? HttpContext.Current.Request.RawUrl? ???? ?? ??? ?? URL? ?????.
???? ??(??) ?? ??). ? GET ??? WeChat ???? ?? ?? ???? echostr ???? ??? ??? ??? ??? ??? ???? ???? ??, ??? ??? ??? ???? ???.
加密/校驗(yàn)流程如下:1.?將token、timestamp、nonce三個(gè)參數(shù)進(jìn)行字典序排序 2.?將三個(gè)參數(shù)字符串拼接成一個(gè)字符串進(jìn)行sha1加密 3.?開(kāi)發(fā)者獲得加密后的字符串可與signature對(duì)比,標(biāo)識(shí)該請(qǐng)求來(lái)源于微信。下面是代碼實(shí)現(xiàn)。首先,在你的處理程序中(我是新建了一個(gè)一般處理程序wx.ashx),判斷當(dāng)前請(qǐng)求的類型,因?yàn)榻尤霑r(shí),是發(fā)送的GET請(qǐng)求,消息處理是發(fā)送的POST請(qǐng)求。如下圖:這里我對(duì)驗(yàn)證url的方法進(jìn)行封裝。/// <summary> /// 驗(yàn)證url權(quán)限, 接入服務(wù)器 /// </summary> /// <param name="token"></param> /// <returns></returns> public static bool ValidUrl(string token) { string echoStr = VqiRequest.GetQueryString("echoStr"); if (CheckSignature(token)) { if (!string.IsNullOrEmpty(echoStr)) { Utils.ResponseWrite(echoStr); return true; } } return false; }/// <summary> /// 驗(yàn)證微信簽名 /// </summary> /// * 將token、timestamp、nonce三個(gè)參數(shù)進(jìn)行字典序排序 /// * 將三個(gè)參數(shù)字符串拼接成一個(gè)字符串進(jìn)行sha1加密 /// * 開(kāi)發(fā)者獲得加密后的字符串可與signature對(duì)比,標(biāo)識(shí)該請(qǐng)求來(lái)源于微信。 /// <returns></returns> public static bool CheckSignature(string token) { string signature = VqiRequest.GetQueryString("signature"); string timestamp = VqiRequest.GetQueryString("timestamp"); string nonce = VqiRequest.GetQueryString("nonce"); string[] ArrTmp = { token, timestamp, nonce }; Array.Sort(ArrTmp); //字典排序 string tmpStr = string.Join("", ArrTmp); tmpStr = Utils.HashPasswordForStoringInConfigFile(tmpStr, "SHA1"); tmpStr = tmpStr.ToLower(); if (tmpStr == signature) { return true; } else { return false; } }??: VqiRequest.GetQueryString ??? ???? QueryString ?? ??????. ?? ? QueryString[""]?? ??? ? ????.
?? ????? ??? ????.
??? ????, ?????, nonce ? ?? ????? ??,
??? ArrTmp:
? ?? ???? ???? ??? ???? ??:
sha1? tmpStr? ????? ???? ???? ???? ?????.
?? ?? ??? ???? ???? ?? ?? ??? ?????.
??? ????? echoStr? WeChat?? ???????.
/// <summary> /// 根據(jù)指定的密碼和哈希算法生成一個(gè)適合于存儲(chǔ)在配置文件中的哈希密碼 /// </summary> /// <param name="str">要進(jìn)行哈希運(yùn)算的密碼</param> /// <param name="type"> 要使用的哈希算法</param> /// <returns>經(jīng)過(guò)哈希運(yùn)算的密碼</returns> public static string HashPasswordForStoringInConfigFile(string str, string type) { return FormsAuthentication.HashPasswordForStoringInConfigFile(str, type); } public static void ResponseWrite(string str) { HttpContext.Current.Response.Write(str); HttpContext.Current.Response.End(); }
?? ???? ?? ? iis? ??(??? Tutorial 1 ??), ??? WeChat ?? ?? mp.weixin?? ?????. ??? ?? ????? "?? ?? ??"? ???? URL, ?? ? EncodingAESKey? ?????. ??? URL? ???? WeChat ??? ???? ? ???? ????? URL???. ???. ??? ???? ???? ??? ???? ? ??? ? ????(??? ??? ???? ?? ????? URL? ??? ??? ?????). EncodingAESKey? ???? ???? ????? ??? ???? ??? ?? ??? ? ?? ?? ?? ?????. ??? ???? ?? ??? ??, ?? ?? ? ?? ?? ? ??? ??? ? ?? ?? ??? ??? ? ????. ?? ?? ? ?? ??? ?? ? ?? ?????. ??? ? ??? ??? ?? ??? ?? ??? ?????. ??? ? ?? ?? ??? ?? ????? ????? ?? ??? ??? ????.
??? ??:
??? ??? ? WeChat ?? ??? ?? ?? URL? ?????. ??? ???? ???? ??? ????.
END
[?? ??]
? ??? WeChat ?? ??? ?? ??? ??? ???? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

PHP? ? ?? ? ?? ? ?????, ?? WeChat ??? ?? ???? ?? ?? ???? ?????. ??? ?? ? ?? ??? ???? WeChat ??? PHP? ???? ???? ????. PHP? ??? ?? ???? ?? ?? ???? ?????. WeChat ???? ??? ??? ? ???? ??? ??? ???? ?? ??? ?? ??? ?????. ??? ? ??? ??? ?? ???? ?? ??? ?? ???? ??? ? ?? ????? ??? ? ? ????.

WeChat ?? ??? ??? ? ?? ??? ?? ?????. ?? ??? ????? ?? ??? ??? ??? ? ?? ?? ????, ??? ?? ? ?? ??? ?? ??? ????? ???. ? ????? PHP? ???? WeChat ?? ??? ???? ??? ?????. WeChat ?? ?? ??? ???? ?? WeChat ?? ?? ??? ??? ???. WeChat ?? ?????? WeChat ?? ??, ?? ?? ? ?? ??? ???? ??? API ??? ???? ???. PHP ??? ???? ???? ???? WeChat?? ????? ???? PH? ???? ???.

WeChat? ??? ?? ?? ? ?? ??? WeChat? ??? ??? ???? ??????. WeChat ?? ??? ??? ??? WeChat ???? ???? ??? ?? ? ?????. ??? ?? ???? ????? ??? ?????? ?? ??? ?? ??? ?? ?????. ??? WeChat ?? ??? ??? ???? ?? ?? ?????. ? ????? PHP? ???? WeChat ?? ??? ??? ???? ??? ?????. 1. ?? ?? WeChat ?? ??? ??? ????? ?? ?? ??? ???? ???. PHP WeChat ?? ??? ??? ?? ?? ?? ?? ??: Sub

WeChat? ?? ???? ?? ? ??? ??? ??? ?? ??? ? ?????. ??? ???? ??? ?? ?? ? ?? ???? WeChat ???? ???? ??? ??????. WeChat ???? ??? ? ?? ???? ??? ?????. ?? ??? ?? ?? ? ? ???? ?? WeChat ??? PHP ??? ??? ? ????. 1. PHP ?? WeChat ?? PHP? ? ?? ???? ?? ???? ?? ?? ?? ? ???? ?????. WeChat ?? ????? ???? ?? ?????? ???? PHP ??? ???? WeChat? ??? ? ????.

WeChat ?? ?? ???? ??? ?? ??? ???? ???? ? ? ???? ??? ? ??? ?? ?? ??? ?????. ? ????? PHP? ???? WeChat ??? ?? ?? ??? ???? ??? ?????. 1. WeChat ???? openid? ?????. WeChat ??? ?? ?? ??? ???? ?? ?? ???? openid? ???? ???. WeChat ?? ??? ??? ? ??? ??? ?? openid? ?? ?? ???? ?????. ??? ??? ???? ?? ??? ?? ???? ?? ? ????.

WeChat? ???? ??? ?? ? ??? ?????? ??? ???, WeChat? ??? ??? ??? ?? ??? ??? ??? ??? ?? ????. ??? ?? WeChat? ??? ????? ???? ?? ??? ??? ???? WeChat ??? ???? ?? ?? ???? ????. ? ? ?? ?? ??? ?? ?? ?????. ???? PHP ??????? ?? ??? ?? ??? ??? ???? ???? ??? ??? ?????. 1. WeChat ?? ??? ??? ?? ??? ?????. ?? ??? ?? ??? ???? ??? ?????.

PHP? ???? WeChat ?? ??? ???? ?? WeChat ?? ??? ?? ??? ?? ? ?? ??? ?? ??? ??? ????, ????? ???? ? ??? PHP? ???? WeChat ?? ??? ??? ?? ????. ? ????? PHP? ???? WeChat ?? ??? ???? ???? ??? ?????. 1??: WeChat ?? ??? ??? ??? ????. WeChat ?? ?? ??? ???? ?? WeChat ?? ??? ??? ??? ???? ???. ???? ?? ??? WeChat ?? ??? ?? ????? ?????.

???? ??? ??? ??? ???? WeChat? ?? ? ??? ???? ???? ?? ??? ?????. ?? ? ?????? ??? WeChat ??? PHP? ???? ??? ?? ???? ??? ?????. ? ????? ?? WeChat ??? PHP? ???? ??? ?? ?? ?? ???? ?? ? ? ?? ??? ?????. 1. ?? ?? ?? WeChat? ???? ?? ?? ?? ?? ??? ???? ???. ??, PHP ?? ??? WeChat ?? ???? ???? ???.
