コード例 #1
0
        //处理微信信息
        public static string  Excute(string postStr)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(postStr);
            string MsgType = xmlDoc.FirstChild.Attributes["MsgType"].Value.ToString();

            switch (MsgType)
            {
            case "image":    //如果是图片消息
                return(WechatMessageService.ResponseImageMessage(postStr));

            case "text":    //如果是文本消息
                return(WechatMessageService.ResponseTextMessage(postStr));

            default:
                return("不被支持的关键字!");
            }

            //WeixinApiDispatch dispatch = new WeixinApiDispatch();
            //string responseContent = dispatch.Execute(postStr);

            //HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;
            //HttpContext.Current.Response.Write(responseContent);
        }
コード例 #2
0
        public static string ResponseTextMessage(string postStr)
        {
            string result     = string.Empty;
            string content    = "测试回复";
            string toUserName = "";

            WechatMessageService.sendMsgToManage(toUserName, content);
            return(result);
        }