/// <summary> /// 处理用户消息 /// </summary> /// <param name="webChatAuthConfig"></param> /// <param name="wxConfig"></param> /// <param name="xml"></param> /// <param name="errCode">错误码</param> public WebChatMessage ProcessRequest(WebChatAuthConfig webChatAuthConfig, WxConfig wxConfig, string xml, int?errCode = null) { WebChatMessage refundReponse = null; try { if (!string.IsNullOrEmpty(Auth(webChatAuthConfig, wxConfig))) { throw new BusinessException("签名错误", HttpStatus.Err.Id); } refundReponse = _xmlProvider.Deserialize <WebChatMessage>(xml); if (refundReponse == null) { throw new BusinessException("参数错误", HttpStatus.Err.Id); } } catch (Exception ex) { _logger.LogError("接受用户信息错误:", ex.ExtractAllStackTrace()); } return(refundReponse); }
/// <summary> /// 处理用户消息 /// </summary> /// <param name="webChatAuthConfig"></param> /// <param name="wxConfig"></param> /// <param name="xml"></param> /// <param name="errCode">错误码</param> public WebChatMessage ProcessRequest(WebChatAuthConfig webChatAuthConfig, WxConfig wxConfig, string xml, int?errCode = null) { WebChatMessage refundReponse = null; try { if (!string.IsNullOrEmpty(Auth(webChatAuthConfig, wxConfig))) { throw new BusinessException("签名错误"); } refundReponse = _xmlProvider.Deserialize <WebChatMessage>(xml); if (refundReponse == null) { throw new BusinessException("参数错误"); } } catch (System.Exception e) { _logService.Error("接受用户信息错误:", e); } return(refundReponse); }
/// <summary> /// 授权认证 /// </summary> /// <returns></returns> public string Auth(WebChatAuthConfig chatAuthConfig, WxConfig wxConfig) { string encodingAesKey = wxConfig.EncodingAesKey; //根据自己后台的设置保持一致 string appId = wxConfig.AppId; //根据自己后台的设置保持一致 string token = wxConfig.Token; //从配置文件获取Token if (string.IsNullOrEmpty(token)) { _logService.Error("WeixinToken 配置项没有配置!"); } if (CheckSignature(token, chatAuthConfig.Signature, chatAuthConfig.Timestamp, chatAuthConfig.Nonce) && !string.IsNullOrEmpty(chatAuthConfig.EchoString)) { return(chatAuthConfig.EchoString); } return(""); }