Ejemplo n.º 1
0
        public static string NewsMsgTest(WxMsgBase obj)
        {
            string s = string.Format(@"<xml>
                        <ToUserName><![CDATA[{1}]]></ToUserName>
                        <FromUserName><![CDATA[{0}]]></FromUserName>
                        <CreateTime>{2}</CreateTime>
                        <MsgType><![CDATA[news]]></MsgType>
                        <ArticleCount>3</ArticleCount>
                        <Articles>
                        <item>
                        <Title><![CDATA[体检项目咨询]]></Title>
                        <Description><![CDATA[]]>
                        </Description>
                        <PicUrl><![CDATA[http://image226-c.poco.cn/mypoco/myphoto/20140410/00/17461923820140410005821040.jpg]]></PicUrl>
                        <Url><![CDATA[http://v.youku.com/v_show/id_XMjAzMTQ0NTc2.html]]></Url>
                        </item>
                        <item>
                        <Title><![CDATA[儿童体检]]></Title>
                        <Description><![CDATA[欢蹦乱跳不代表健康 在现实生活中,年轻的父母总是凭经验、凭肉眼观察判断孩子是否健康,认为只要欢蹦乱跳就没毛病,其实这也是一种误解。 比如有的...]]>
                        </Description>
                        <PicUrl><![CDATA[http://img226.poco.cn/mypoco/myphoto/20140410/00/17461923820140410003736048.jpg]]></PicUrl>
                        <Url><![CDATA[http://image226-c.poco.cn/mypoco/myphoto/20140410/02/17461923820140410023518075.jpg]]></Url>
                        </item>
                        <item>
                        <Title><![CDATA[老年人体检]]></Title>
                        <Description><![CDATA[随着年龄的增长,身体的各项机能逐渐下降,定期为老年人进行身体检查十分必要。以下7项,是老年人身体检查必须涉及的项目...]]></Description>
                        <PicUrl><![CDATA[http://img226.poco.cn/mypoco/myphoto/20140410/00/17461923820140410003750044.jpg]]></PicUrl>
                        <Url><![CDATA[http://image226-c.poco.cn/mypoco/myphoto/20140410/02/17461923820140410023518075.jpg]]></Url>
                        </item>
                        </Articles>
                        </xml> ", obj.ToUserName, obj.FromUserName, obj.CreateTime);

            return s;
        }
Ejemplo n.º 2
0
        public static WxMsgBase Create(Stream inputStream)
        {
            XmlDocument xmlDoc = StreamToXml(inputStream);

            XmlElement rootElment = xmlDoc["xml"];

            var obj = new WxMsgBase(rootElment);

            //#region 测试接收手机发送的数据

            //string s = "";
            //foreach (XmlNode node in rootElment.ChildNodes)
            //{
            //    s += node.Name + "=" + node.InnerText + "|";
            //    foreach (XmlNode node2 in node.ChildNodes)
            //    {
            //        s += node2.Name + "=" + node2.InnerText + "|";
            //    }
            //}

            //TestContent.SendMail(s);

            //#endregion

            switch (obj.MsgType.ToLower())
            {
                case "text":
                    obj = new WxTextMsg(rootElment);
                    break;
                case "event":

                    obj = new WxEventMsg(rootElment);
                    break;
            }

            return obj;
        }
Ejemplo n.º 3
0
        //private static string TOKEN = "ldy";
        protected void Page_Load(object sender, EventArgs e)
        {
            Test t = new Test();

            if (!IsPostBack)
            {
                #region 首次接入微信服务器验证

                string echostr = Request["echostr"];
                if (!string.IsNullOrEmpty(echostr))
                {
                    Response.Clear();
                    Response.Write(echostr);
                    return;
                }

                #endregion

                //验证token
                var obj = new WxMsgBase();

                try
                {
                    obj = WxMsgFactory.Create(Request.InputStream);

                    string reMst = obj.GetResponeXml();

                    Response.Write(reMst);
                }

                catch (Exception exception)
                {
                    Response.Write(exception.Message);
                }
            }
        }