110,525
社区成员
发帖
与我相关
我的任务
分享
[HttpGet]
[Route("GetByModel")] //路由路径
public HttpResponseMessage GetByModel(string signature, string timestamp, string nonce, string echostr)
{
try
{
string EchoStr = valid(token, signature, timestamp, nonce, echostr);
if (!string.IsNullOrEmpty(EchoStr))
{
return ToHttpMsgForWeChat(echostr);
}
else
{
return ToHttpMsgForWeChat("验证失败!");
}
}
catch (Exception ex)
{
return ToHttpMsgForWeChat(ex.ToString());
}
}
[HttpPost]
//[Route("GetByModel")] //路由路径
/// <summary>
/// 接收用户发送的消息
/// </summary>
public void GetByModel()
{
try
{
HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];//获取传统context
HttpRequestBase request = context.Request;//定义传统request对象
HttpResponseBase response = context.Response;
string echostr = request.Params["echostr"];
string signature = request.Params["signature"];
string timestamp = request.Params["timestamp"];
string nonce = request.Params["nonce"];
//LogHelper.WriteLog("测试测试");
if (!CheckSignature(token, signature, timestamp, nonce))
{
//WeLogger.Debug("验证消息真实性---失败!");
response.Write(string.Empty);
response.End();
return;
}
string data = ReadStream2String(request.InputStream);
string responseData = ParseMessage(data);
response.Write(responseData);
response.End();
}
catch (Exception ex)
{
//LogHelper.WriteLog(ex.ToString());
}
}