微信小程序想实现 模板消息推送的话
1.登录到微信公众平台 – 小程序 – 开发 – 开发设置 。 找到消息推送
2.验证消息的确来自微信服务器
微信只提供了php检验的代码段,还缺少返回参数的方法
// GET: Common
///
/// 微信小程序模板校验签名
///
///
[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.填写服务器配置
然后就可以填写服务器配置,提交验证签名了!