/// <summary> /// 获取企业平台配置对象 /// </summary> /// <returns></returns> public static WXQYConfigEntity GetQYConfig() { string strXmlPath = HttpRuntime.AppDomainAppPath + @"bin\xmlConfig\WXQYConfig.xml"; WXQYConfigEntity qyConfig = SetWXConfigCache("WxQyConfig", strXmlPath, "QYConfig", new WXQYConfigEntity()); return(qyConfig); }
/// <summary> /// 企业号处理 /// </summary> /// <returns></returns> private string QYProcess() { WXQYConfigEntity qyConfig = XmlToEntity.GetQYConfig(); string strMsg = string.Empty; //校验签名及返回解析后的content CheckMsgSignature(ref strMsg); return(strMsg); }
/// <summary> /// 类初始化 /// </summary> /// <param name="wxPlatType"></param> public PassiveProcess(WxPlatFormTypeEnum wxPlatType) { this._wxPlatType = wxPlatType; //根据平台构造加解密实例,目前将qy与gz使用同一加解密实例 if (this._wxPlatType == WxPlatFormTypeEnum.QY) { WXQYConfigEntity qyConfig = XmlToEntity.GetQYConfig(); this._wxcpt = new WXBizMsgCrypt(qyConfig.Token, qyConfig.EncodingAESKey, qyConfig.CorpID); } else { WXGZConfigEntity gzConfig = XmlToEntity.GetGZConfig(); this._wxcpt = new WXBizMsgCrypt(gzConfig.Token, gzConfig.EncodingAESKey, gzConfig.AppID); } }
/// <summary> /// 企业号返回验证结果 /// </summary> /// <returns></returns> public string GetQYValidityResult() { QYValidityEntity validityEntity = Request2Entity(this._request, new QYValidityEntity()); if (validityEntity == null) { return(""); } WXQYConfigEntity qyConfig = XmlToEntity.GetQYConfig(); WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(qyConfig.Token, qyConfig.EncodingAESKey, qyConfig.CorpID); int ret = 0; string sEchoStr = ""; ret = wxcpt.VerifyURL(validityEntity.Msg_Signature, validityEntity.Timestamp, validityEntity.Nonce, validityEntity.echostr, ref sEchoStr); if (ret != 0) { //System.Console.WriteLine( "ERR: VerifyURL fail, ret: " + ret ); return(""); } return(sEchoStr); }