Пример #1
0
        public void sendmaterial(string text, string openid)
        {
            string[]                str          = openid.Split('|');
            Business.material       material     = new Business.material();
            Business.materialData[] materialdata = material.Select(text);
            string imgfile = "../uploads/" + materialdata[0].materialfile;


            switch (materialdata[0].materialtype)
            {
            case ("1"):
                var voice    = MaterialLib.Add(HttpContext.Current.Server.MapPath(imgfile), AccessTokenBox.GetTokenValue(), MaterialType.voice);
                var voiceret = GroupSend.SendVoiceByOpenID(voice.media_id, AccessTokenBox.GetTokenValue(), str);
                break;

            case ("2"):
                var image    = MaterialLib.Add(HttpContext.Current.Server.MapPath(imgfile), AccessTokenBox.GetTokenValue(), MaterialType.image);
                var imageret = GroupSend.SendImgByOpenID(image.media_id, AccessTokenBox.GetTokenValue(), str);
                break;

            case ("3"):
                var video    = MaterialLib.Add(HttpContext.Current.Server.MapPath(imgfile), AccessTokenBox.GetTokenValue(), MaterialType.video);
                var videoret = GroupSend.SendVideoByOpenID(video.media_id, AccessTokenBox.GetTokenValue(), str);
                break;

            default: break;
            }
        }
Пример #2
0
        public void ProcessRequest(HttpContext context)
        {
            var accessToken = AccessTokenBox.GetTokenValue("wxf50808b364418ffb", "bfaf8363dc64787091b3bbb7740dcf44");
            var res         = MaterialLib.Add("D:/MyRepository/WeChatDevelopment/Material/voice/test.mp3", accessToken, MaterialType.voice, false, "voiceTitleDemo", "videoIntroDemo");

            if (res.ErrCode == 0)
            {
                context.Response.Write("语音消息发送成功!media_id为:" + res.media_id);
            }
            else
            {
                context.Response.Write("语音消息发送失败!错误消息是:" + res.ErrDescription);
            }
        }
Пример #3
0
        protected void BtnYes_Click(object sender, EventArgs e)
        {
            Business.userinfo userinfo = new Business.userinfo();

            //清除用户列表
            userinfo.DeleteByCase("");

            var accessToken = AccessTokenBox.GetTokenValue();
            //获取用户列表
            var ret = BaseUser.GetUserList(accessToken, "");

            for (int i = 0; i < ret.data.openid.Count; i++)
            {
                var data = BaseUser.GetUserInfo(ret.data.openid[i], accessToken);

                Business.userinfoData userinfodata = new Business.userinfoData();
                userinfodata.subscribe      = data.subscribe.ToString();
                userinfodata.openid         = data.openid;
                userinfodata.nickname       = data.nickname;
                userinfodata.sex            = data.sex.ToString() == "1" ? "男" : "女";
                userinfodata.language       = data.language;
                userinfodata.city           = data.city;
                userinfodata.province       = data.province;
                userinfodata.country        = data.country;
                userinfodata.headimgurl     = data.headimgurl;
                userinfodata.subscribe_time = data.subscribe_time.ToString();
                userinfodata.unionid        = data.unionid == null ? "" : data.unionid;
                userinfodata.remark         = data.remark;
                if (data.privilege == null)
                {
                    userinfodata.privilege = "";
                }
                else
                {
                    userinfodata.privilege = data.privilege.ToString();
                }
                userinfo.Insert(userinfodata);
            }
            //var reet = BaseUser.GetUserInfo(ret.data.openid[0], accessToken);
        }
Пример #4
0
        public void sendarticle(string text, string openid)
        {
            string[]               str         = openid.Split('|');
            Business.article       article     = new Business.article();
            Business.articleData[] articledata = article.Select(text);
            string imgfile = "../uploads/" + articledata[0].thumb_media_id;
            var    img     = MaterialLib.Add(HttpContext.Current.Server.MapPath(imgfile), AccessTokenBox.GetTokenValue(), MaterialType.image);
            var    ret     = GroupSend.UpLoadNew(new List <Article> {
                new Article
                {
                    title              = articledata[0].title,
                    author             = articledata[0].author,
                    content            = articledata[0].content,
                    content_source_url = "https://www.baidu.com/",
                    digest             = articledata[0].digest,
                    show_cover_pic     = 1,
                    thumb_media_id     = img.media_id
                }
            }, AccessTokenBox.GetTokenValue());

            var ss = WxApi.GroupSend.SendArticleByOpenID(ret.media_id, AccessTokenBox.GetTokenValue(), str);
        }
Пример #5
0
 public void sendtext(string text, string openid)
 {
     string[] str = openid.Split('|');
     var      ss  = GroupSend.SendTextByOpenID(text, AccessTokenBox.GetTokenValue(), str);
 }
        public void ProcessRequest(HttpContext context)
        {
            #region 创建菜单按钮
            string appid       = "wxf50808b364418ffb";
            string appSerect   = "bfaf8363dc64787091b3bbb7740dcf44";
            var    accessToken = AccessTokenBox.GetTokenValue(appid, appSerect);
            var    child1      = new List <BaseMenu>();
            var    child2      = new List <BaseMenu>();
            var    child3      = new List <BaseMenu>();
            var    basebtn     = new List <BaseMenu>();
            string rUrl        = OAuth.GetAuthUrl("wxf50808b364418ffb", "http://skywalkerxl.free.ngrok.cc/UnusedEntering.html", "success");



            child1.Add(new BaseMenu
            {
                url  = rUrl,
                name = "闲置对比",
                type = MenuType.view
            });
            child1.Add(new BaseMenu
            {
                url  = "http://skywalkerxl.free.ngrok.cc/UnusedEntering.html",
                name = "闲置录入",
                type = MenuType.view
            });

            child2.Add(new BaseMenu
            {
                key  = "SelectionClick",
                name = "精选好物",
                type = MenuType.click
            });
            child2.Add(new BaseMenu
            {
                url  = "http://skywalkerxl.free.ngrok.cc/SearchYouWant.html",
                name = "搜你所想",
                type = MenuType.view
            });

            child3.Add(new BaseMenu
            {
                url  = "http://skywalkerxl.free.ngrok.cc/MyInfomation.html",
                name = "我的信息",
                type = MenuType.view
            });

            child3.Add(new BaseMenu
            {
                url  = "http://skywalkerxl.free.ngrok.cc/RecentActivity.html",
                name = "最近活动",
                type = MenuType.view
            });
            child3.Add(new BaseMenu
            {
                url  = "http://skywalkerxl.free.ngrok.cc/UseGuide.html",
                name = "使用指南",
                type = MenuType.view
            });
            child3.Add(new BaseMenu
            {
                url  = "http://skywalkerxl.free.ngrok.cc/FeedBack.html",
                name = "意见反馈",
                type = MenuType.view
            });
            child3.Add(new BaseMenu
            {
                url  = "http://skywalkerxl.free.ngrok.cc/AboutUs.html",
                name = "关于我们",
                type = MenuType.view
            });

            basebtn.Add(new BaseMenu
            {
                name       = "出售闲置",
                sub_button = child1
            });
            basebtn.Add(new BaseMenu
            {
                name       = "精选好物",
                sub_button = child2
            });
            basebtn.Add(new BaseMenu
            {
                name       = "查看更多",
                sub_button = child3
            });

            /*
             * child1.Add(new BaseMenu
             * {
             *  key = "我是click按钮",
             *  name = "Click按钮",
             *  type = MenuType.click
             * });
             * child1.Add(new BaseMenu
             * {
             *  key = "我是选择地理位置按钮",
             *  name = "选择地理位置",
             *  type = MenuType.location_select
             * });
             * child1.Add(new BaseMenu
             * {
             *  url = "http://skywalkerxl.free.ngrok.cc/WxJs.aspx",
             *  name = "跳转链接",
             *  type = MenuType.view
             * });
             *
             * child2.Add(new BaseMenu
             * {
             *  key = "我是扫码事件按钮",
             *  name = "扫码推事件",
             *  type = MenuType.scancode_push
             * });
             * child2.Add(new BaseMenu
             * {
             *  key = "我是扫码推事件按钮且弹出消息接收中",
             *  name = "扫码等待",
             *  type = MenuType.scancode_waitmsg
             * });
             *
             * child3.Add(new BaseMenu
             * {
             *  key = "我是拍照或相册按钮",
             *  name = "拍照或相册",
             *  type = MenuType.pic_photo_or_album
             * });
             *
             * child3.Add(new BaseMenu
             * {
             *  key = "我是系统拍照",
             *  name = "系统拍照",
             *  type = MenuType.pic_sysphoto
             * });
             * child3.Add(new BaseMenu
             * {
             *  key = "我是弹出微信相册按钮",
             *  name = "微信相册",
             *  type = MenuType.pic_weixin
             * });
             *
             * basebtn.Add(new BaseMenu
             * {
             *  name = "常用菜单",
             *  sub_button = child1
             * });
             * basebtn.Add(new BaseMenu
             * {
             *  name = "扫码",
             *  sub_button = child2
             * });
             * basebtn.Add(new BaseMenu
             * {
             *  name = "发图",
             *  sub_button = child3
             * });
             */

            var ret = WxApi.Menu.Create(new MenuEntity {
                button = basebtn
            }, accessToken);
            context.Response.Write("状态码:" + ret.ErrCode + "状态描述:" + ret.ErrDescription);
            #endregion
        }