예제 #1
0
        /// <summary>
        /// 根据Post参数获取对应处理事件
        /// </summary>
        /// <param name="postParamater"></param>
        /// <returns></returns>
        public static WeChatHandle GetWeChatHandle(U_WeChatCallbackParameter wcp, Stream inputStream)
        {
            string      postParamater = WeChatCallbackLogic.GetPostParameter(wcp, inputStream);
            XmlDocument xmldoc        = new XmlDocument();

            xmldoc.Load(new System.IO.MemoryStream(System.Text.Encoding.GetEncoding("GB2312").GetBytes(postParamater)));
            XmlNode MsgType = xmldoc.SelectSingleNode("/xml/MsgType");

            WeChatHandle weChatHandle = null;

            if (MsgType != null)
            {
                switch (MsgType.InnerText)
                {
                case "event":
                    weChatHandle = new WeChatEventHandle(wcp, xmldoc);    //事件处理
                    break;

                case "text":
                    weChatHandle = new WeChatTextHandle(wcp, xmldoc);    //事件处理
                    break;

                default:
                    break;
                }
            }
            return(weChatHandle);
        }
예제 #2
0
        public static string GetPostParameter(U_WeChatCallbackParameter wcp, Stream inputStream)
        {
            Byte[] postBytes = new Byte[inputStream.Length];
            inputStream.Read(postBytes, 0, (Int32)inputStream.Length);
            string postString   = Encoding.UTF8.GetString(postBytes);
            string postParmater = WeChatCallbackLogic.DecryptMessage(wcp, postString);

            return(postParmater);
        }