Esempio n. 1
0
        private string PostMessageNIMEI()
        {
            ContentModel content = new ContentModel()
            {
                content = "感谢您的支持!"
            };
            TextMessageModel textModel = new TextMessageModel()
            {
                text    = content,
                touser  = entity.FromUser,
                msgtype = MsgType.text.ToString()
            };
            string json = JsonHelper.JsonSerializer(textModel);

            FileMessageSave.MessageSave(json);

            WeixinMessagePost msgPost = new WeixinMessagePost();

            msgPost.MsgUrl = string.Format(WeiXinCommon.MessageSend, WeiXinCommon.Access_token);
            string      result = msgPost.PostMessage(json);
            ResultModel model  = JsonHelper.JsonDeserialize <ResultModel>(result);

            if (model.errcode == "0")
            {
                return("success");
            }
            else
            {
                return(model.errmsg);
            }
        }
Esempio n. 2
0
        private string PostMessageNIMEI()
        {
            var zhArray = new List <string>()
            {
                "你妹", "卧槽", "f**k", "二彩", "二采"
            };
            var wmArray = new List <string>()
            {
                "谢谢", "你好"
            };
            string content = string.Empty;

            if (zhArray.IndexOf(entity.Content) >= 0)
            {
                content = "请做文明人,请温文尔雅!";
            }
            else if (wmArray.IndexOf(entity.Content) >= 0)
            {
                content = "你好我好大家好!";
            }
            else
            {
                content = "我什么都不知道啊!";
            }
            ContentModel contentModel = new ContentModel()
            {
                content = content
            };
            TextMessageModel textModel = new TextMessageModel()
            {
                text    = contentModel,
                touser  = entity.FromUser,
                msgtype = MsgType.text.ToString()
            };

            string message = JsonHelper.JsonSerializer(textModel);

            FileMessageSave.MessageSave(message);

            WeixinMessagePost msgPost = new WeixinMessagePost();

            msgPost.MsgUrl = string.Format(WeiXinCommon.MessageSend, WeiXinCommon.Access_token);
            string result = msgPost.PostMessage(message);

            ResultModel model = JsonHelper.JsonDeserialize <ResultModel>(result);

            if (model.errcode == "0")
            {
                return("success");
            }
            else
            {
                return(model.errmsg);
            }
        }
Esempio n. 3
0
        public string ReadStreamAndReply(HttpRequestBase request)
        {
            string txt = new WeiXinCommon().PostInput(request, Encoding.UTF8);

            FileMessageSave.MessageSave(txt);

            XmlDocument xml = new XmlDocument();

            xml.LoadXml(txt);
            XmlElement          xe     = xml.DocumentElement;
            WeixinMessageEntity entity = ModelCommon.ConsoleXmlToModel(xe);

            MessageFactory factory = new MessageFactory(entity);
            var            message = factory.ConsoleMessage();

            FileMessageSave.MessageSave(message);
            return(message);
        }
Esempio n. 4
0
        public string UpdateOwnMenu()
        {
            string json = JsonHelper.JsonSerializer(new WeiXinMenuRule().CreateMenu());

            FileMessageSave.MessageSave(json);
            WeixinMessagePost msgPost = new WeixinMessagePost();

            msgPost.MsgUrl = string.Format(WeiXinCommon.MenuCreate, WeiXinCommon.Access_token);
            string      result = msgPost.PostMessage(json);
            ResultModel model  = JsonHelper.JsonDeserialize <ResultModel>(result);

            if (model.errcode == "0")
            {
                return("success");
            }
            else
            {
                return(model.errmsg);
            }
        }