接入微信公众平台开发,开发者需要按照如下步骤完成:
URL
后,微信服务器会发送GET
请求,并携带以下参数:
signature
:微信加密签名timestamp
:时间戳nonce
:随机数echostr
:随机字符串比如我在微信公众平台服务器配置中进行如下配置:
[Route("api/[controller]")]
[ApiController]
public class MPController : ControllerBase
{
[HttpGet]
public ActionResult<string> Get(string signature, string timestamp, string nonce, string echostr)
{
string[] tmpArr = { "huayueniansi", timestamp, nonce };
Array.Sort(tmpArr);// 字典排序
string tmpStr = string.Join("", tmpArr);
tmpStr = SHA1Helper.SHA1Crypto(tmpStr);
tmpStr = tmpStr.ToLower();
if (tmpStr == signature && !string.IsNullOrWhiteSpace(echostr))
return echostr;
return "";
}
}
原文地址:https://www.jianshu.com/p/001f0ca5abf8
原文:https://www.cnblogs.com/huayueniansi/p/10456348.html