Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 扫一扫
        /// </summary>
        public static void ResponseAdvClickEvent(HttpResponseBase Response, MsgModel msg, ResultCryptography ccg)
        {
            string remsg  = string.Empty;
            string openid = msg.FromUserName;
            //LogHelper.WriteLog("lalal" + ConfigurationManager.AppSettings["ScanCodeInfoUrl"] + "?url=" + System.Web.HttpUtility.UrlEncode(msg.EventModel.ClickEventModel.ScanResult) + "&openid=" + openid);
            //调用积分url
            string ret = BasicApi.RequestCreate(ConfigurationManager.AppSettings["ScanCodeInfoUrl"] + "?url=" + System.Web.HttpUtility.UrlEncode(msg.EventModel.ClickEventModel.ScanResult) + "&openid=" + openid);

            //LogHelper.WriteLog(ConfigurationManager.AppSettings["ScanCodeInfoUrl"]);

            msg.TextModel = new TextModel()
            {
                Content = ret
            };
            remsg = XmlHelpler.GetTextXml(msg);
            Response.Write(GetMsg(remsg, ccg));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 创建菜单
        /// </summary>
        /// <param name="Response"></param>
        /// <param name="msg"></param>
        public static void CreateMenu()
        {
            StringBuilder sb   = new StringBuilder();
            string        url  = ConfigurationManager.AppSettings["WeiXinDomain"];
            string        json = "{\"button\":[" +
                                 "{\"name\":\"我的\",\"sub_button\":[" +
                                 "{\"type\":\"view\",\"name\":\"我的账户\",\"url\":\"" + url + "component/personal\"}," +
                                 "{\"type\":\"view\",\"name\":\"我要注册\",\"url\":\"" + url + "component/register\"}," +
                                 "{\"type\":\"view\",\"name\":\"会员须知\",\"url\":\"" + url + "component/membernotice\"}," +
                                 "{\"type\": \"scancode_waitmsg\",\"name\": \"扫一扫\",\"key\": \"rselfmenu_0_1\",\"sub_button\": [ ]}]" +
                                 "}," +
                                 "{\"name\":\"家味\",\"sub_button\":[" +
                                 "{\"type\":\"view\",\"name\":\"积分红包\",\"url\":\"http://mp.weixin.qq.com/s/5H6_rnk86ai2fOs-ChI2Gg\"}," +
                                 "{\"type\":\"view\",\"name\":\"免费抽奖\",\"url\":\"" + url + "component/hometastedraw\"}," +
                                 "{\"type\":\"view\",\"name\":\"年夜饭菜谱\",\"url\":\"" + url + "component/menu\"}]" +
                                 "}," +
                                 "{\"name\":\"积分活动\",\"sub_button\":[" +
                                 "{\"type\":\"view\",\"name\":\"每日签到\",\"url\":\"" + url + "component/sign\"}," +
                                 "{\"type\":\"view\",\"name\":\"积分兑换\",\"url\":\"" + url + "component/shop\"}," +
                                 "{\"type\":\"view\",\"name\":\"积分抽奖\",\"url\":\"" + url + "component/integraldraw\"}," +
                                 "{\"type\":\"view\",\"name\":\"扫码规则\",\"url\":\"" + url + "component/activityrule\"}]" +
                                 "}" +
                                 "]}";

            // string json = "{\"button\":[" +
            //       "{\"name\":\"我的\",\"sub_button\":[" +
            //             "{\"type\":\"view\",\"name\":\"我的账户\",\"url\":\"http://testjifenweixin.shinho.net.cn/#/component/personal\"}," +
            //             "{\"type\":\"view\",\"name\":\"我要注册\",\"url\":\"http://testjifenweixin.shinho.net.cn/#/component/register\"}," +
            //             "{\"type\":\"view\",\"name\":\"会员须知\",\"url\":\"http://testjifenweixin.shinho.net.cn/#/component/membernotice\"}," +
            //             "{\"type\": \"scancode_waitmsg\",\"name\": \"扫一扫\",\"key\": \"rselfmenu_0_1\",\"sub_button\": [ ]}]" +
            //       "}," +
            //       "{\"name\":\"家味\",\"sub_button\":[" +
            //     "{\"type\":\"view\",\"name\":\"每日资讯\",\"url\":\"http://m.linkshop.com/news/show.aspx?id=394095&from=singlemessage\"}," +
            //             "{\"type\":\"view\",\"name\":\"年夜饭菜谱\",\"url\":\"" + url + "component/menu\"}]" +
            //       "}," +
            //       "{\"name\":\"积分活动\",\"sub_button\":[" +
            //             "{\"type\":\"view\",\"name\":\"积分红包\",\"url\":\"http://mp.weixin.qq.com/s/5H6_rnk86ai2fOs-ChI2Gg\"}," +
            //             "{\"type\":\"view\",\"name\":\"每日签到\",\"url\":\"http://testjifenweixin.shinho.net.cn/#/component/sign\"}," +
            //             "{\"type\":\"view\",\"name\":\"积分兑换\",\"url\":\"" + url + "component/shop\"}," +
            //             "{\"type\":\"view\",\"name\":\"积分抽奖\",\"url\":\"" + url + "component/integraldraw\"}," +
            //             "{\"type\":\"view\",\"name\":\"扫码规则\",\"url\":\"" + url + "component/activityrule\"}]" +
            //       "}" +
            //"]}";
            PostJson("https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + BasicApi.GetAccessToken(), json);
        }
Ejemplo n.º 7
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());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 关注事件
        /// </summary>
        /// <param name="httpRequest"></param>
        /// <param name="msg"></param>
        public static void ResponseSubscribeEvent(HttpResponseBase Response, MsgModel msg, ResultCryptography ccg)
        {
            string openid = msg.FromUserName;
            string ret    = BasicApi.RequestCreate(ConfigurationManager.AppSettings["AddFollowerOpenId"] + "?id=" + msg.EventModel.EventKeyModel.EventKey + "&openid=" + openid);
            var    remsg  = "";

            try
            {
                string str = msg.EventModel.EventKeyModel.EventKey;
                if (!string.IsNullOrEmpty(str))
                {
                    int Id = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(str, @"[^0-9]+", ""));
                    if (Id < 10000 && Id > 0)
                    {
                        msg.MsgType = "news";
                        ArticelModel articel = new ArticelModel()
                        {
                            Title       = "味达美厨师会员招募啦!点击图片即可注册!",
                            Description = "积分好礼、国内外学习考察、新品试用等你来!",
                            PicUrl      = "https://mmbiz.qpic.cn/mmbiz_jpg/uuwJXDpEBqsSZZuaafJUZfNibZ109B0CXbWpLSaKEdQdibozC0LOibu9Eshs0R1yfgFNOYvI0icb7ntDKXC2k06tVw/0?wx_fmt=jpeg",
                            Url         = ConfigurationManager.AppSettings["WeiXinDomain"] + "component/register"
                        };
                        ArticelModel articel2 = new ArticelModel()
                        {
                            Title       = "会员扫码须知",
                            Description = "会员扫码须知",
                            PicUrl      = "https://mmbiz.qpic.cn/mmbiz_jpg/uuwJXDpEBqtaGUZZoklAKp1sE9eqTK2Mia7RSpH0AyT3lP5BaxNJkiagobOIz3Gpe2ZQs3HYz8icFKw3wxic35KApQ/0?wx_fmt=jpeg",
                            Url         = "http://jifenweixin.shinho.net.cn/#/component/activityrule"
                        };
                        ArticelModel articel3 = new ArticelModel()
                        {
                            Title       = "即日起至2月10日,凡任务达标者即可瓜分20万积分红包!",
                            Description = "即日起至2月10日,凡任务达标者即可瓜分20万积分红包!",
                            PicUrl      = "https://mmbiz.qpic.cn/mmbiz_jpg/uuwJXDpEBqtIndjMF7wbHqDy3CVVvrmTHXAdA9QtewoUvqgazfLlCmfhjExN3HuHk7sbtgp6trxNqt64Z01uqA/0?wx_fmt=jpeg",
                            Url         = "http://mp.weixin.qq.com/s/5H6_rnk86ai2fOs-ChI2Gg"
                        };

                        msg.Articles = new List <ArticelModel>();
                        msg.Articles.Add(articel);
                        msg.Articles.Add(articel2);
                        msg.Articles.Add(articel3);
                        remsg = XmlHelpler.GetArticlesXml(msg);
                    }
                    else
                    {
                        msg.MsgType = "news";
                        ArticelModel articel = new ArticelModel()
                        {
                            Title       = "味达美厨师会员招募啦!点击图片即可注册!",
                            Description = "积分好礼、国内外学习考察、新品试用等你来!",
                            PicUrl      = "https://mmbiz.qpic.cn/mmbiz_jpg/uuwJXDpEBqsSZZuaafJUZfNibZ109B0CXbWpLSaKEdQdibozC0LOibu9Eshs0R1yfgFNOYvI0icb7ntDKXC2k06tVw/0?wx_fmt=jpeg",
                            Url         = ConfigurationManager.AppSettings["WeiXinDomain"] + "component/register"
                        };

                        msg.Articles = new List <ArticelModel>();
                        msg.Articles.Add(articel);
                        remsg = XmlHelpler.GetArticlesXml(msg);
                    }
                }
                else
                {
                    msg.MsgType = "news";
                    ArticelModel articel = new ArticelModel()
                    {
                        Title       = "味达美厨师会员招募啦!点击图片即可注册!",
                        Description = "积分好礼、国内外学习考察、新品试用等你来!",
                        PicUrl      = "https://mmbiz.qpic.cn/mmbiz_jpg/uuwJXDpEBqsSZZuaafJUZfNibZ109B0CXbWpLSaKEdQdibozC0LOibu9Eshs0R1yfgFNOYvI0icb7ntDKXC2k06tVw/0?wx_fmt=jpeg",
                        Url         = ConfigurationManager.AppSettings["WeiXinDomain"] + "component/register"
                    };
                    ArticelModel articel2 = new ArticelModel()
                    {
                        Title       = "会员扫码须知",
                        Description = "会员扫码须知",
                        PicUrl      = "https://mmbiz.qpic.cn/mmbiz_jpg/uuwJXDpEBqtaGUZZoklAKp1sE9eqTK2Mia7RSpH0AyT3lP5BaxNJkiagobOIz3Gpe2ZQs3HYz8icFKw3wxic35KApQ/0?wx_fmt=jpeg",
                        Url         = "http://jifenweixin.shinho.net.cn/#/component/activityrule"
                    };
                    ArticelModel articel3 = new ArticelModel()
                    {
                        Title       = "即日起至2月10日,凡任务达标者即可瓜分20万积分红包!",
                        Description = "即日起至2月10日,凡任务达标者即可瓜分20万积分红包!",
                        PicUrl      = "https://mmbiz.qpic.cn/mmbiz_jpg/uuwJXDpEBqtIndjMF7wbHqDy3CVVvrmTHXAdA9QtewoUvqgazfLlCmfhjExN3HuHk7sbtgp6trxNqt64Z01uqA/0?wx_fmt=jpeg",
                        Url         = "http://mp.weixin.qq.com/s/5H6_rnk86ai2fOs-ChI2Gg"
                    };
                    msg.Articles = new List <ArticelModel>();
                    msg.Articles.Add(articel);
                    msg.Articles.Add(articel2);
                    msg.Articles.Add(articel3);
                    remsg = XmlHelpler.GetArticlesXml(msg);
                }
            }
            catch
            {
                msg.MsgType = "news";
                ArticelModel articel = new ArticelModel()
                {
                    Title       = "味达美厨师会员招募啦!点击图片即可注册!",
                    Description = "积分好礼、国内外学习考察、新品试用等你来!",
                    PicUrl      = "https://mmbiz.qpic.cn/mmbiz_jpg/uuwJXDpEBqsSZZuaafJUZfNibZ109B0CXbWpLSaKEdQdibozC0LOibu9Eshs0R1yfgFNOYvI0icb7ntDKXC2k06tVw/0?wx_fmt=jpeg",
                    Url         = ConfigurationManager.AppSettings["WeiXinDomain"] + "component/register"
                };
                ArticelModel articel2 = new ArticelModel()
                {
                    Title       = "会员扫码须知",
                    Description = "会员扫码须知",
                    PicUrl      = "https://mmbiz.qpic.cn/mmbiz_jpg/uuwJXDpEBqtaGUZZoklAKp1sE9eqTK2Mia7RSpH0AyT3lP5BaxNJkiagobOIz3Gpe2ZQs3HYz8icFKw3wxic35KApQ/0?wx_fmt=jpeg",
                    Url         = "http://jifenweixin.shinho.net.cn/#/component/activityrule"
                };
                ArticelModel articel3 = new ArticelModel()
                {
                    Title       = "即日起至2月10日,凡任务达标者即可瓜分20万积分红包!",
                    Description = "即日起至2月10日,凡任务达标者即可瓜分20万积分红包!",
                    PicUrl      = "https://mmbiz.qpic.cn/mmbiz_jpg/uuwJXDpEBqtIndjMF7wbHqDy3CVVvrmTHXAdA9QtewoUvqgazfLlCmfhjExN3HuHk7sbtgp6trxNqt64Z01uqA/0?wx_fmt=jpeg",
                    Url         = "http://mp.weixin.qq.com/s/5H6_rnk86ai2fOs-ChI2Gg"
                };
                msg.Articles = new List <ArticelModel>();
                msg.Articles.Add(articel);
                msg.Articles.Add(articel2);
                msg.Articles.Add(articel3);
                remsg = XmlHelpler.GetArticlesXml(msg);
            }

            Response.Write(GetMsg(remsg, ccg));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 创建队员关注二维码
        /// </summary>
        public static string CreateSubscribeQRcode(int salemanId)
        {
            string json = "{\"expire_seconds\": 1800, \"action_name\": \"QR_SCENE\", \"action_info\": {\"scene\": {\"scene_id\": " + salemanId.ToString() + "}}}";
            string ret  = PostJson("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + BasicApi.GetAccessToken(), json);
            var    q    = JsonHelper.JsonToObject <QRcode>(ret);

            return(q.ticket);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 1注册成功给1发模板消息
 /// </summary>
 /// <param name="Response"></param>
 /// <param name="msg"></param>
 public static void SendMuBanMsg(string json)
 {
     PostJson("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + BasicApi.GetAccessToken(), json);
 }