[C#] 纯文本查看 复制代码
protected void Page_Load(object sender, EventArgs e)
{
//开启消息接受
if (Request.HttpMethod.ToUpper() == "GET")
{
......
}
else if (Request.HttpMethod.ToUpper() == "POST")
{
byte[] btHtml = Request.BinaryRead(Request.ContentLength);
string strHtml = System.Text.Encoding.Default.GetString(btHtml);
string signature = HttpContext.Current.Request.QueryString["msg_signature"];
string timestamp = HttpContext.Current.Request.QueryString["timestamp"];
string nonce = HttpContext.Current.Request.QueryString["nonce"];
string decryptEchoString = "";
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WXConfig.sToken, WXConfig.sEncodingAESKey, WXConfig.sCorpID);
int ret = wxcpt.DecryptMsg(signature, timestamp, nonce, strHtml, ref decryptEchoString);
LogHelper.WriteLog("微信异步回调内容:" + decryptEchoString);
if (!string.IsNullOrEmpty(decryptEchoString))
{
try
{
var m_values = get_m_values(decryptEchoString);
//获取InfoType =action
string InfoType = InputHelper.GetInputString(m_values["InfoType"]);
switch (InfoType)
{
case "suite_ticket": // 微信推送suite_ticket
var suite_ticket = m_values["SuiteTicket"].ToString();
if (!string.IsNullOrEmpty(suite_ticket))
{
// 存储suite_ticket
var edit_result = cachebll.Update(DictBuilder.Assign("suite_ticket", suite_ticket).Assign("suite_ticket_update", DateTime.Now), $" suite_id='{WXConfig.SuiteID}'", null);
}
break;
}
}
catch (Exception ex)
{
//LogHelper.WriteLog("异步回调异常:" + ex.Message.ToString());
}
}
}
}