예제 #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
        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);
        }