微信小程序想實現 模板消息推送的話
1.登錄到微信公眾平台 - 小程序 - 開發 - 開發設置 。 找到消息推送
2.驗證消息的確來自微信服務器
微信只提供了php檢驗的代碼段,還缺少返回參數的方法
// GET: Common /// <summary> /// 微信小程序模板校驗簽名 /// </summary> /// <returns></returns> [System.Web.Http.HttpGet] public void CheckSignature(string signature, string timestamp, string nonce, string echostr) { var token = ConfigurationManager.AppSettings["Token"]; string[] ArrTmp = { token, timestamp, nonce }; Array.Sort(ArrTmp); string tmpStr = string.Join("", ArrTmp); tmpStr = FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "SHA1"); tmpStr = tmpStr.ToLower(); if (tmpStr == signature) { HttpContext.Current.Response.Write(echostr); HttpContext.Current.Response.End(); } HttpContext.Current.Response.Write("校驗失敗"); HttpContext.Current.Response.End(); }
3.填寫服務器配置
然后就可以填寫服務器配置,提交驗證簽名了!
轉載於:https://www.cnblogs.com/rock-dx/p/10560939.html