? ???? ASP.NET WeChat ?? ????? ???? ??? ?????. WeChat ?? ???? ??? ??? ?????. ?? ?? ???? ??? ? ????.
?? ??? ???? ??? ??? ? WeChat ??? ?????. GET ??? ??? URL? ???? ?? 4?? ????? ?????.
???? ??? ???? ??? ?????(?? ?? ??? ??). ?? GET ??? WeChat ???? ?? ??? ???? echostr ???? ??? ??? ??? ??? ??? ????, ??? ??? ??? ?????.
??? ???? ??? ?? ????? ??? ????? ???? ? nonce ????? ?????.
???/?? ??:
1. ? ?? ???? ??, ?????, nonce? ????? ?????.
2. sha1 ???? ?? ? ?? ???? ???? ??? ???? ?????
3. ???? ???? ???? ??? ??? ? ????.
/// <summary> /// 驗(yàn)證簽名 /// </summary> /// <param name="signature"></param> /// <param name="timestamp"></param> /// <param name="nonce"></param> /// <returns></returns> public static bool CheckSignature(String signature, String timestamp, String nonce) { String[] arr = new String[] { token, timestamp, nonce }; // 將token、timestamp、nonce三個(gè)參數(shù)進(jìn)行字典序排序 Array.Sort<String>(arr); StringBuilder content = new StringBuilder(); for (int i = 0; i < arr.Length; i++) { content.Append(arr[i]); } String tmpStr = SHA1_Encrypt(content.ToString()); // 將sha1加密后的字符串可與signature對(duì)比,標(biāo)識(shí)該請(qǐng)求來(lái)源于微信 return tmpStr != null ? tmpStr.Equals(signature) : false; } /// <summary> /// 使用缺省密鑰給字符串加密 /// </summary> /// <param name="Source_String"></param> /// <returns></returns> public static string SHA1_Encrypt(string Source_String) { byte[] StrRes = Encoding.Default.GetBytes(Source_String); HashAlgorithm iSHA = new SHA1CryptoServiceProvider(); StrRes = iSHA.ComputeHash(StrRes); StringBuilder EnText = new StringBuilder(); foreach (byte iByte in StrRes) { EnText.AppendFormat("{0:x2}", iByte); } return EnText.ToString(); }
?? ? ?? WeChat ????? ??? ??? ?????. ?? ??? ???? ??? WeChat ??? ??? URL? ???? ?????.
protected void Page_Load(object sender, EventArgs e) { if (Request.HttpMethod.ToUpper() == "GET") { // 微信加密簽名 string signature = Request.QueryString["signature"]; // 時(shí)間戳 string timestamp = Request.QueryString["timestamp"]; // 隨機(jī)數(shù) string nonce = Request.QueryString["nonce"]; // 隨機(jī)字符串 string echostr = Request.QueryString["echostr"]; if (WeixinServer.CheckSignature(signature, timestamp, nonce)) { Response.Write(echostr); } } else if (Request.HttpMethod.ToUpper() == "POST") { StreamReader stream = new StreamReader(Request.InputStream); string xml = stream.ReadToEnd(); processRequest(xml); } } /// <summary> /// 處理微信發(fā)來(lái)的請(qǐng)求 /// </summary> /// <param name="xml"></param> public void processRequest(String xml) { try { // xml請(qǐng)求解析 Hashtable requestHT = WeixinServer.ParseXml(xml); // 發(fā)送方帳號(hào)(open_id) string fromUserName = (string)requestHT["FromUserName"]; // 公眾帳號(hào) string toUserName = (string)requestHT["ToUserName"]; // 消息類型 string msgType = (string)requestHT["MsgType"]; //文字消息 if (msgType == ReqMsgType.Text) { // Response.Write(str); string content = (string)requestHT["Content"]; if(content=="1") { // Response.Write(str); Response.Write(GetNewsMessage(toUserName, fromUserName)); return; } if (content == "2") { Response.Write(GetUserBlogMessage(toUserName, fromUserName)); return; } if (content == "3") { Response.Write(GetGroupMessage(toUserName, fromUserName)); return; } if (content == "4") { Response.Write(GetWinePartyMessage(toUserName, fromUserName)); return; } Response.Write(GetMainMenuMessage(toUserName, fromUserName, "你好,我是vinehoo,")); } else if (msgType == ReqMsgType.Event) { // 事件類型 String eventType = (string)requestHT["Event"]; // 訂閱 if (eventType==ReqEventType.Subscribe) { Response.Write(GetMainMenuMessage(toUserName, fromUserName, "謝謝您的關(guān)注!,")); } // 取消訂閱 else if (eventType==ReqEventType.Unsubscribe) { // TODO 取消訂閱后用戶再收不到公眾號(hào)發(fā)送的消息,因此不需要回復(fù)消息 } // 自定義菜單點(diǎn)擊事件 else if (eventType==ReqEventType.CLICK) { // TODO 自定義菜單權(quán)沒有開放,暫不處理該類消息 } } else if (msgType == ReqMsgType.Location) { } } catch (Exception e) { } }<pre name="code" class="csharp"> protected void Page_Load(object sender, EventArgs e) { if (Request.HttpMethod.ToUpper() == "GET") { // 微信加密簽名 string signature = Request.QueryString["signature"]; // 時(shí)間戳 string timestamp = Request.QueryString["timestamp"]; // 隨機(jī)數(shù) string nonce = Request.QueryString["nonce"]; // 隨機(jī)字符串 string echostr = Request.QueryString["echostr"]; if (WeixinServer.CheckSignature(signature, timestamp, nonce)) { Response.Write(echostr); } } else if (Request.HttpMethod.ToUpper() == "POST") { StreamReader stream = new StreamReader(Request.InputStream); string xml = stream.ReadToEnd(); processRequest(xml); } } /// <summary> /// 處理微信發(fā)來(lái)的請(qǐng)求 /// </summary> /// <param name="xml"></param> public void processRequest(String xml) { try { // xml請(qǐng)求解析 Hashtable requestHT = WeixinServer.ParseXml(xml); // 發(fā)送方帳號(hào)(open_id) string fromUserName = (string)requestHT["FromUserName"]; // 公眾帳號(hào) string toUserName = (string)requestHT["ToUserName"]; // 消息類型 string msgType = (string)requestHT["MsgType"]; //文字消息 if (msgType == ReqMsgType.Text) { // Response.Write(str); string content = (string)requestHT["Content"]; if(content=="1") { // Response.Write(str); Response.Write(GetNewsMessage(toUserName, fromUserName)); return; } if (content == "2") { Response.Write(GetUserBlogMessage(toUserName, fromUserName)); return; } if (content == "3") { Response.Write(GetGroupMessage(toUserName, fromUserName)); return; } if (content == "4") { Response.Write(GetWinePartyMessage(toUserName, fromUserName)); return; } Response.Write(GetMainMenuMessage(toUserName, fromUserName, "你好,我是vinehoo,")); } else if (msgType == ReqMsgType.Event) { // 事件類型 String eventType = (string)requestHT["Event"]; // 訂閱 if (eventType==ReqEventType.Subscribe) { Response.Write(GetMainMenuMessage(toUserName, fromUserName, "謝謝您的關(guān)注!,")); } // 取消訂閱 else if (eventType==ReqEventType.Unsubscribe) { // TODO 取消訂閱后用戶再收不到公眾號(hào)發(fā)送的消息,因此不需要回復(fù)消息 } // 自定義菜單點(diǎn)擊事件 else if (eventType==ReqEventType.CLICK) { // TODO 自定義菜單權(quán)沒有開放,暫不處理該類消息 } } else if (msgType == ReqMsgType.Location) { } } catch (Exception e) { } }
? ??? ASP.NET WeChat ?? ????? ???? ?? ??? ??? ????? ?? ??? ??? ??? ??? ????. .
? ??? ASP.NET 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 ?? ???? ???? ???.
