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 static MediaUpload Add(string access_token, MediaType type, string filePath, string title = null, string introduction = null) { if (type == MediaType.News) { throw new NotSupportedException(); } var file = new Dictionary <string, string> { ["media"] = filePath }; if (type == MediaType.Video) { file["description"] = JsonCreate.Add(title, introduction); } return(ApiPostFile <MediaUpload>(file, "/cgi-bin/material/add_material?access_token={0}", access_token)); }
public void WeChatApiCustomerServiceAccountManageTest() { Assert.AreEqual(JsonCreate.Add("test1@test", "客服1"), "{\"kf_account\":\"test1@test\",\"nickname\":\"客服1\"}"); Assert.AreEqual(JsonCreate.Invite("test1@test", "test_kfwx"), "{\"kf_account\":\"test1@test\",\"invite_wx\":\"test_kfwx\"}"); Assert.AreEqual(JsonCreate.Update("test1@test", "客服1"), "{\"kf_account\":\"test1@test\",\"nickname\":\"客服1\"}"); //var token = Api.GetAccessToken(Config); //var account = Api.CustomerService.GetList(token); //var online = Api.CustomerService.GetOnlineList(token); //var add = Api.CustomerService.Account.Add(token, "测试01", "test1", Config); //var invite = Api.CustomerService.Account.Invite(token, "ouyangminlan", "test1", Config); //var update = Api.CustomerService.Account.Update(token, "测试号", "test1@maiqunw"); //var upload = Api.CustomerService.Account.UploadHeadImg(token, @"C:\Users\Vic\Desktop\www.100qun.com.jpg", "test1", Config); //var del = Api.CustomerService.Account.Delete(token, "test1", Config); //var record = Api.CustomerService.Record.GetMsgList(token, DateTime.Now.AddHours(-1), DateTime.Now); }
public static JsonResult Add(string access_token, string kf_account, string nickname) => ApiPost <JsonResult>(JsonCreate.Add(kf_account, nickname), "/customservice/kfaccount/add?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); }
public static Model.Template Add(string access_token, string template_id_short) => ApiPost <Model.Template>(JsonCreate.Add(template_id_short), "/cgi-bin/template/api_add_template?access_token={0}", access_token);