コード例 #1
0
 public WechatContext(WechatMsgRequestModel request)
 {
     Logger.Debug("微信服务器消息:" + JsonConvert.SerializeObject(request));
     _securityHelper = new WechatSecurityHelper(request.Msg_Signature, request.Timestamp, request.Nonce);
     _requestMessage = _securityHelper.DecryptMsg(request.RequestContent);
     Logger.Debug("收到微信消息:" + _requestMessage);
 }
コード例 #2
0
        public async System.Threading.Tasks.Task <string> GetResponseAsync()
        {
            var requestMessage  = _securityHelper.DecryptMsg(_requestMessage);
            var responseMessage = await MpWechatMsgHandler.ReturnMessageAsync(requestMessage);

            Logger.Debug($"request:{requestMessage}, response:{responseMessage}");
            if (responseMessage.IsNotNullOrEmpty())
            {
                return(_securityHelper.EncryptMsg(responseMessage));
            }
            return(string.Empty);
        }