public void WeChatApiTemplateTest()
            {
                var data = new List <Model.TemplateParameter>()
                {
                    new Model.TemplateParameter("first", "恭喜你购买成功!"),
                    new Model.TemplateParameter("keynote1", "巧克力"),
                    new Model.TemplateParameter("keynote2", "39.8元"),
                    new Model.TemplateParameter("keynote3", "2014年9月22日"),
                    new Model.TemplateParameter("remark", "欢迎再次购买!")
                };

                Assert.AreEqual(JsonCreate.SendMessage("OPENID", "ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY", "http://weixin.qq.com/download", data),
                                "{\"touser\":\"OPENID\",\"template_id\":\"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY\",\"url\":\"http://weixin.qq.com/download\",\"data\":{\"first\":{\"value\":\"恭喜你购买成功!\",\"color\":\"#173177\"},\"keynote1\":{\"value\":\"巧克力\",\"color\":\"#173177\"},\"keynote2\":{\"value\":\"39.8元\",\"color\":\"#173177\"},\"keynote3\":{\"value\":\"2014年9月22日\",\"color\":\"#173177\"},\"remark\":{\"value\":\"欢迎再次购买!\",\"color\":\"#173177\"}}}");
                Assert.AreEqual(JsonCreate.SendMessage("OPENID", "ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY", "http://weixin.qq.com/download", data, "xiaochengxuappid12345", "index?foo=bar"),
                                "{\"touser\":\"OPENID\",\"template_id\":\"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY\",\"url\":\"http://weixin.qq.com/download\",\"miniprogram\":{\"appid\":\"xiaochengxuappid12345\",\"pagepath\":\"index?foo=bar\"},\"data\":{\"first\":{\"value\":\"恭喜你购买成功!\",\"color\":\"#173177\"},\"keynote1\":{\"value\":\"巧克力\",\"color\":\"#173177\"},\"keynote2\":{\"value\":\"39.8元\",\"color\":\"#173177\"},\"keynote3\":{\"value\":\"2014年9月22日\",\"color\":\"#173177\"},\"remark\":{\"value\":\"欢迎再次购买!\",\"color\":\"#173177\"}}}");

                Assert.AreEqual(JsonCreate.SetIndustry(IndustryCode.IT科技_互联网_电子商务, IndustryCode.IT科技_电子技术), "{\"industry_id1\":\"1\",\"industry_id2\":\"4\"}");
                Assert.AreEqual(JsonCreate.Add("TM00015"), "{\"template_id_short\":\"TM00015\"}");
                Assert.AreEqual(JsonCreate.Delete("Dyvp3-Ff0cnail_CDSzk1fIc6-9lOkxsQE7exTJbwUE"), "{\"template_id\":\"Dyvp3-Ff0cnail_CDSzk1fIc6-9lOkxsQE7exTJbwUE\"}");

                //Config = new Api.Config("gh_69438e79ea75", "wx95dfa97f9fca2358", "4e053f53f278347179416898e3d7883a");
                //var openid = "okOeUwaD9TRRqFh_hyE4xlMwBg8Y";
                //var token = Api.GetAccessToken(Config);
                //var send = Api.Template.SendMessage(token, openid, "avmLDdQFqlD9wGJyO5uFR7Y5IKylPYf2A6ZEt7frlxg", "", "",
                //    new Dictionary<string, string>()
                //    {
                //        {"test","测试"},
                //        {"name","名字" }
                //    });
                //var set = Api.Template.SetIndustry(token, IndustryCode.IT科技_电子技术, IndustryCode.IT科技_互联网_电子商务);
                //var industry = Api.Template.GetIndustry(token);
                //var add = Api.Template.Add(token, "TM00001");
                //var get = Api.Template.Get(token);
                //var del = Api.Template.Delete(token, get[0].template_id);
            }
            public void WeChatApiTagsTest()
            {
                Assert.AreEqual(JsonCreate.Create("广东"), "{\"tag\":{\"name\":\"广东\"}}");
                Assert.AreEqual(JsonCreate.Update(134, "广东人"), "{\"tag\":{\"id\":134,\"name\":\"广东人\"}}");
                Assert.AreEqual(JsonCreate.Delete(134), "{\"tag\":{\"id\":134}}");
                Assert.AreEqual(JsonCreate.GetUsers(134), "{\"tagid\":134,\"next_openid\":\"\"}");
                Assert.AreEqual(JsonCreate.GetUsers(134, "test"), "{\"tagid\":134,\"next_openid\":\"test\"}");
                Assert.AreEqual(JsonCreate.GetIdList("test"), "{\"openid\":\"test\"}");

                //Config = new Api.Config("gh_69438e79ea75", "wx95dfa97f9fca2358", "4e053f53f278347179416898e3d7883a");
                //var token = Api.GetAccessToken(Config);
                //var create = Api.Tags.Create(token, "测试");
                //var tags = Api.Tags.Get(token);
                //var update = Api.Tags.Update(token, create.id, "test");
                //tags = Api.Tags.Get(token);
                //var del = Api.Tags.Delete(token, create.id);
                //tags = Api.Tags.Get(token);
                //var users = Api.Tags.GetUsers(token, tags[0].id);
                //var ids = Api.Tags.GetIdList(token, "oOk2XjhrbcHP3tGgzDGAVHppo3Bs");
            }
Beispiel #3
0
 public static JsonResult Delete(string access_token, string media_id) =>
 ApiPost <JsonResult>(JsonCreate.Delete(media_id), "/cgi-bin/material/del_material?access_token={0}", access_token);
Beispiel #4
0
 public static JsonResult Delete(string access_token, int id) =>
 ApiPost <JsonResult>(JsonCreate.Delete(id), "/cgi-bin/tags/delete?access_token={0}", access_token);
            public void WeChatApiMediaTest()
            {
                //Api.Media.Upload(Api.GetAccessToken(Config), MediaType.Image, @"C:\Users\Vic\Desktop\topbar_logo.png");

                Assert.AreEqual(Api.Media.GetUrl("test", MediaType.Image, "demoMediaId"), "https://api.weixin.qq.com/cgi-bin/media/get?access_token=test&media_id=demoMediaId");
                Assert.AreEqual(Api.Media.SpeexDownloadUrl("test", "demoMediaId"), "https://api.weixin.qq.com/cgi-bin/media/get/jssdk?access_token=test&media_id=demoMediaId");

                Assert.AreEqual(Api.Material.MiniProgramContentXml("wx123123123", "pages/index/index", "小程序示例", "http://mmbizqbic.cn/demo.jpg"), "<mp-miniprogram data-miniprogram-appid=\"wx123123123\" data-miniprogram-path=\"pages/index/index\" data-miniprogram-title=\"小程序示例\" data-progarm-imageurl=\"http://mmbizqbic.cn/demo.jpg\"></mp-miniprogram>");

                Assert.AreEqual(JsonCreate.AddNews(new List <Model.Article>()
                {
                    new Model.Article()
                    {
                        title              = "TITLE",
                        thumb_media_id     = "THUMB_MEDIA_ID",
                        author             = "AUTHOR",
                        digest             = "DIGEST",
                        show_cover_pic     = false,
                        content            = "CONTENT",
                        content_source_url = "CONTENT_SOURCE_URL"
                    }
                }), "{\"articles\":[{\"title\":\"TITLE\",\"thumb_media_id\":\"THUMB_MEDIA_ID\",\"author\":\"AUTHOR\",\"digest\":\"DIGEST\",\"show_cover_pic\":0,\"content\":\"CONTENT\",\"content_source_url\":\"CONTENT_SOURCE_URL\"}]}");
                Assert.AreEqual(JsonCreate.Add("VIDEO_TITLE", "INTRODUCTION"), "{\"title\":\"VIDEO_TITLE\",\"introduction\":\"INTRODUCTION\"}");

                var getRequest = "{\"media_id\":\"MEDIA_ID\"}";

                Assert.AreEqual(JsonCreate.GetVideoInfo("MEDIA_ID"), getRequest);
                Assert.AreEqual(JsonCreate.GetNews("MEDIA_ID"), getRequest);
                Assert.AreEqual(JsonCreate.Delete("MEDIA_ID"), getRequest);

                Assert.AreEqual(JsonCreate.UpdateNews("MEDIA_ID", 1, new Model.Article()
                {
                    title              = "TITLE",
                    thumb_media_id     = "THUMB_MEDIA_ID",
                    author             = "AUTHOR",
                    digest             = "DIGEST",
                    show_cover_pic     = true,
                    content            = "CONTENT",
                    content_source_url = "CONTENT_SOURCE_URL"
                }), "{\"media_id\":\"MEDIA_ID\",\"index\":1,\"articles\":{\"title\":\"TITLE\",\"thumb_media_id\":\"THUMB_MEDIA_ID\",\"author\":\"AUTHOR\",\"digest\":\"DIGEST\",\"show_cover_pic\":1,\"content\":\"CONTENT\",\"content_source_url\":\"CONTENT_SOURCE_URL\"}}");

                Assert.AreEqual(JsonCreate.BatchGet("image", 0, 20), "{\"type\":\"image\",\"offset\":0,\"count\":20}");
                Assert.AreEqual(JsonCreate.BatchGetNews(0, 20), "{\"type\":\"news\",\"offset\":0,\"count\":20}");

                //var data = Api.Material.Add(Api.GetAccessToken(Config), MediaType.Image, @"C:\Users\Vic\Desktop\topbar_logo.png");
                //var url = Api.Material.UploadImage(Api.GetAccessToken(Config), @"C:\Users\Vic\Desktop\topbar_logo.png");
                //var newsMediaId = Api.Material.AddNews(Api.GetAccessToken(Config),
                //     new Model.MaterialNew()
                //     {
                //         title = "接口测试",
                //         thumb_media_id = data.media_id,
                //         author = "测试",
                //         digest = "测试信息",
                //         show_cover_pic = true,
                //         content = "测试呀",
                //         content_source_url = "http://www.qq.com/"
                //     }, new Model.MaterialNew()
                //     {
                //         title = "接口测试",
                //         thumb_media_id = data.media_id,
                //         author = "测试",
                //         digest = "测试信息",
                //         show_cover_pic = true,
                //         content = "测试呀",
                //         content_source_url = "http://www.qq.com/"
                //     }
                //     );
                //Api.Material.Get(Api.GetAccessToken(Config), MediaType.Image, data.media_id);
                //var newsData = Api.Material.GetNews(Api.GetAccessToken(Config), newsMediaId);
                //Api.Material.UpdateNews(Api.GetAccessToken(Config), newsMediaId, 1, new Model.MaterialNew()
                //{
                //    title = "接口测试" + DateTime.Now.ToTimeString(),
                //    thumb_media_id = data.media_id,
                //    author = "测试",
                //    digest = "测试信息",
                //    show_cover_pic = true,
                //    content = "测试呀",
                //    content_source_url = "http://www.qq.com/"
                //});

                //Api.Material.Delete(Api.GetAccessToken(Config), data.media_id);
                //Api.Material.Delete(Api.GetAccessToken(Config), newsMediaId);

                //var count = Api.Material.Count(Api.GetAccessToken(Config));
                //var batch = Api.Material.BatchGet(Api.GetAccessToken(Config), MediaType.Image, 0, 10);
                //var news = Api.Material.BatchGetNews(Api.GetAccessToken(Config), 0, 10);
            }
Beispiel #6
0
 public static JsonResult Delete(string access_token, string template_id) =>
 ApiPost <JsonResult>(JsonCreate.Delete(template_id), "/cgi-bin/template/del_private_template?access_token={0}", access_token);