Пример #1
0
        /// <summary>
        /// 回复文本消息XML
        /// </summary>
        /// <param name="httpRequest"></param>
        /// <param name="msg"></param>
        public static string GetTextXml(MsgModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<xml>");
            sb.Append("<ToUserName><![CDATA[" + model.FromUserName + "]]></ToUserName>");
            sb.Append("<FromUserName><![CDATA[" + model.ToUserName + "]]></FromUserName>");
            sb.Append("<CreateTime>" + BasicApi.LocalTimeToEpochTimeSeconds(DateTime.Now) + "</CreateTime>");
            sb.Append("<MsgType><![CDATA[text]]></MsgType>");
            sb.Append("<Content><![CDATA[" + model.TextModel.Content + "]]></Content>");
            sb.Append("<FuncFlag>0<FuncFlag>");
            sb.Append("</xml>");
            return(sb.ToString());
        }
Пример #2
0
        /// <summary>
        /// 回复图片消息XML
        /// </summary>
        /// <param name="httpRequest"></param>
        /// <param name="msg"></param>
        public static string GetImageXml(MsgModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<xml>");
            sb.Append("<ToUserName><![CDATA[" + model.FromUserName + "]]></ToUserName>");
            sb.Append("<FromUserName><![CDATA[" + model.ToUserName + "]]></FromUserName>");
            sb.Append("<CreateTime>" + BasicApi.LocalTimeToEpochTimeSeconds(DateTime.Now) + "</CreateTime>");
            sb.Append("<MsgType><![CDATA[" + model.MsgType + "]]></MsgType>");
            sb.Append("<Image>");
            sb.Append("<MediaId><![CDATA[" + model.ImageModel.MediaId + "]]></MediaId>");
            sb.Append("</Image>");
            sb.Append("</xml>");
            return(sb.ToString());
        }
Пример #3
0
        /// <summary>
        /// 扫描带参数二维码
        /// </summary>
        /// <param name="msg"></param>
        public static string GetScanningParametersXml(MsgModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<xml>");
            sb.Append("<ToUserName><![CDATA[" + model.FromUserName + "]]></ToUserName>");
            sb.Append("<FromUserName><![CDATA[" + model.ToUserName + "]]></FromUserName>");
            sb.Append("<CreateTime>" + BasicApi.LocalTimeToEpochTimeSeconds(DateTime.Now) + "</CreateTime>");
            sb.Append("<MsgType><![CDATA[event]]></MsgType>");
            sb.Append("<Event><![CDATA[" + model.EventModel.Event + "]]></Event>");
            sb.Append("<EventKey><![CDATA[" + model.EventModel.EventKeyModel.EventKey + "]]><EventKey>");
            sb.Append("<Ticket><![CDATA[" + model.EventModel.EventKeyModel.Ticket + "]]><Ticket>");
            sb.Append("</xml>");
            return(sb.ToString());
        }
Пример #4
0
        /// <summary>
        /// 回复视频消息XML
        /// </summary>
        /// <param name="httpRequest"></param>
        /// <param name="msg"></param>
        public static string GetVideoXml(MsgModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<xml>");
            sb.Append("<ToUserName><![CDATA[" + model.FromUserName + "]]></ToUserName>");
            sb.Append("<FromUserName><![CDATA[" + model.ToUserName + "]]></FromUserName>");
            sb.Append("<CreateTime>" + BasicApi.LocalTimeToEpochTimeSeconds(DateTime.Now) + "</CreateTime>");
            sb.Append("<MsgType><![CDATA[" + model.MsgType + "]]></MsgType>");
            sb.Append("<Video>");
            sb.Append("<MediaId><![CDATA[" + model.VideoModel.MediaId + "]]></MediaId>");
            sb.Append("<Title><![CDATA[" + model.VideoModel.Title + "]]></Title>");
            sb.Append("<Description><![CDATA[" + model.VideoModel.Description + "]]></Description>");
            sb.Append("</Video>");
            sb.Append("</xml>");
            return(sb.ToString());
        }
Пример #5
0
        /// <summary>
        /// 回复图文消息XML
        /// </summary>
        /// <param name="httpRequest"></param>
        /// <param name="msg"></param>
        public static string GetArticlesXml(MsgModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<xml>");
            sb.Append("<ToUserName><![CDATA[" + model.FromUserName + "]]></ToUserName>");
            sb.Append("<FromUserName><![CDATA[" + model.ToUserName + "]]></FromUserName>");
            sb.Append("<CreateTime>" + BasicApi.LocalTimeToEpochTimeSeconds(DateTime.Now) + "</CreateTime>");
            sb.Append("<MsgType><![CDATA[" + model.MsgType + "]]></MsgType>");
            sb.Append("<ArticleCount><![CDATA[" + model.Articles.Count + "]]></ArticleCount>");
            sb.Append("<Articles>");
            foreach (var item in model.Articles)
            {
                sb.Append("<item>");
                sb.Append("<Title><![CDATA[" + item.Title + "]]></Title>");
                sb.Append("<Description><![CDATA[" + item.Description + "]]></Description>");
                sb.Append("<PicUrl><![CDATA[" + item.PicUrl + "]]></PicUrl>");
                sb.Append("<Url><![CDATA[" + item.Url + "]]></Url>");
                sb.Append("</item>");
            }
            sb.Append("</Articles>");
            sb.Append("</xml>");
            return(sb.ToString());
        }