Ejemplo n.º 1
0
        public static string GetReplyMsg()
        {
            var doc   = WXUtil.GetMsgXML();
            var mType = WXUtil.GetContentFromWX(doc, WXUtil.WXConstant.KEY_MsgType);

            if (mType == WXUtil.WXConstant.MsgType_Text)
            {
                return(ReplyText(doc));
            }

            return("success");   // success 或空字符串,微信不会提示服务器无法响应
        }
Ejemplo n.º 2
0
        private static string ReplyText(XmlDocument doc)
        {
            var con   = WXUtil.GetContentFromWX(doc, WXUtil.WXConstant.KEY_Content);
            var frm   = WXUtil.GetContentFromWX(doc, WXUtil.WXConstant.KEY_FromUserName);
            var to    = WXUtil.GetContentFromWX(doc, WXUtil.WXConstant.KEY_ToUserName);
            var cre   = WXUtil.GetContentFromWX(doc, WXUtil.WXConstant.KEY_CreateTime);
            var msgId = WXUtil.GetContentFromWX(doc, WXUtil.WXConstant.KEY_MsgId);

            string tpl_txt = HttpContext.Current.Server.MapPath(WXUtil.WXConstant.TPL_ReplyTxt);
            var    outDoc  = new XmlDocument();

            outDoc.Load(tpl_txt);
            outDoc.SelectSingleNode("xml").SelectSingleNode(WXUtil.WXConstant.KEY_ToUserName).InnerText   = frm;
            outDoc.SelectSingleNode("xml").SelectSingleNode(WXUtil.WXConstant.KEY_FromUserName).InnerText = to;
            outDoc.SelectSingleNode("xml").SelectSingleNode(WXUtil.WXConstant.KEY_CreateTime).InnerText   = DateUtil.GetTimestamp();
            outDoc.SelectSingleNode("xml").SelectSingleNode(WXUtil.WXConstant.KEY_MsgType).InnerText      = WXUtil.WXConstant.MsgType_Text;
            outDoc.SelectSingleNode("xml").SelectSingleNode(WXUtil.WXConstant.KEY_Content).InnerText      = TuLingUtil.GetReply(con);

            string outStr = XmlUtil.ConvertXmlToString(outDoc);

            return(outStr);
        }