public void WeChatApiCustomerServiceSessionTest() { string sessionRequest = "{\"kf_account\":\"test1@test\",\"openid\":\"OPENID\"}"; Assert.AreEqual(JsonCreate.Create("test1@test", "OPENID"), sessionRequest); Assert.AreEqual(JsonCreate.Close("test1@test", "OPENID"), sessionRequest); //var token = Api.GetAccessToken(Config); //var openid = "okOeUwaD9TRRqFh_hyE4xlMwBg8Y"; //var create = Api.CustomerService.Session.Create(token, openid, "test1", Config); //var get = Api.CustomerService.Session.Get(token, openid); //var getlist = Api.CustomerService.Session.GetList(token, "test1", Config); //var getwait = Api.CustomerService.Session.GetWaitCase(token); //var close = Api.CustomerService.Session.Close(token, openid, "test1", Config); }
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"); }
public static JsonResult Create(string access_token, List <MenuBase> buttons) => ApiPost <JsonResult>(JsonCreate.Create(buttons), "/cgi-bin/menu/create?access_token={0}", access_token);
public static TagResult.Tag Create(string access_token, string name) => ApiPost <TagResult>(JsonCreate.Create(name), "/cgi-bin/tags/create?access_token={0}", access_token).tag;
public void WeChatApiMenuTest() { //Config = new Api.Config("gh_69438e79ea75", "wx95dfa97f9fca2358", "4e053f53f278347179416898e3d7883a"); Assert.AreEqual(JsonCreate.Create(new List <Model.MenuBase>() { new Model.MenuClick("今日歌曲", "V1001_TODAY_MUSIC"), new Model.MenuTop("菜单", new List <Model.MenuBase>() { new Model.MenuView("搜索", "http://www.soso.com/"), new Model.MenuMiniProgram("wxa", "wx286b93c14bbf93aa", "pages/lunar/index.html", "http://mp.weixin.qq.com"), new Model.MenuClick("赞一下我们", "V1001_GOOD") }) }), "{\"button\":[{\"type\":\"click\",\"name\":\"今日歌曲\",\"key\":\"V1001_TODAY_MUSIC\"},{\"name\":\"菜单\",\"sub_button\":[{\"type\":\"view\",\"name\":\"搜索\",\"url\":\"http://www.soso.com/\"},{\"type\":\"miniprogram\",\"name\":\"wxa\",\"url\":\"http://mp.weixin.qq.com\",\"appid\":\"wx286b93c14bbf93aa\",\"pagepath\":\"pages/lunar/index.html\"},{\"type\":\"click\",\"name\":\"赞一下我们\",\"key\":\"V1001_GOOD\"}]}]}"); Assert.AreEqual(JsonCreate.Create(new List <Model.MenuBase>() { new Model.MenuTop("扫码", new List <Model.MenuBase>() { new Model.MenuScanWait("扫码带提示", "rselfmenu_0_0"), new Model.MenuScanPush("扫码推事件", "rselfmenu_0_1") }), new Model.MenuTop("发图", new List <Model.MenuBase>() { new Model.MenuSysPhoto("系统拍照发图", "rselfmenu_1_0"), new Model.MenuPhotoOrAlbum("拍照或者相册发图", "rselfmenu_1_1"), new Model.MenuPicWeixin("微信相册发图", "rselfmenu_1_2") }), new Model.MenuLocationSelect("发送位置", "rselfmenu_2_0"), new Model.MenuMedia("图片", "MEDIA_ID1"), new Model.MenuViewLimited("图文消息", "MEDIA_ID2") }), "{\"button\":[{\"name\":\"扫码\",\"sub_button\":[{\"type\":\"scancode_waitmsg\",\"name\":\"扫码带提示\",\"key\":\"rselfmenu_0_0\"},{\"type\":\"scancode_push\",\"name\":\"扫码推事件\",\"key\":\"rselfmenu_0_1\"}]},{\"name\":\"发图\",\"sub_button\":[{\"type\":\"pic_sysphoto\",\"name\":\"系统拍照发图\",\"key\":\"rselfmenu_1_0\"},{\"type\":\"pic_photo_or_album\",\"name\":\"拍照或者相册发图\",\"key\":\"rselfmenu_1_1\"},{\"type\":\"pic_weixin\",\"name\":\"微信相册发图\",\"key\":\"rselfmenu_1_2\"}]},{\"type\":\"location_select\",\"name\":\"发送位置\",\"key\":\"rselfmenu_2_0\"},{\"type\":\"media_id\",\"name\":\"图片\",\"media_id\":\"MEDIA_ID1\"},{\"type\":\"view_limited\",\"name\":\"图文消息\",\"media_id\":\"MEDIA_ID2\"}]}"); Assert.AreEqual(JsonCreate.AddCondition(new Model.MenuMatchRule() { TagId = 2, Sex = MenuMatchSex.男, Country = "中国", Province = "广东", City = "广州", ClientPlatformType = Enums.MenuMatchPlatform.Android, Language = MenuMatchLanguage.简体中文 }, new List <Model.MenuBase>() { new Model.MenuClick("今日歌曲", "V1001_TODAY_MUSIC"), new Model.MenuTop("菜单", new List <Model.MenuBase>() { new Model.MenuView("搜索", "http://www.soso.com/"), new Model.MenuMiniProgram("wxa", "wx286b93c14bbf93aa", "pages/lunar/index.html", "http://mp.weixin.qq.com"), new Model.MenuClick("赞一下我们", "V1001_GOOD") }) }), "{\"button\":[{\"type\":\"click\",\"name\":\"今日歌曲\",\"key\":\"V1001_TODAY_MUSIC\"},{\"name\":\"菜单\",\"sub_button\":[{\"type\":\"view\",\"name\":\"搜索\",\"url\":\"http://www.soso.com/\"},{\"type\":\"miniprogram\",\"name\":\"wxa\",\"url\":\"http://mp.weixin.qq.com\",\"appid\":\"wx286b93c14bbf93aa\",\"pagepath\":\"pages/lunar/index.html\"},{\"type\":\"click\",\"name\":\"赞一下我们\",\"key\":\"V1001_GOOD\"}]}],\"matchrule\":{\"tag_id\":\"2\",\"sex\":\"1\",\"country\":\"中国\",\"province\":\"广东\",\"city\":\"广州\",\"client_platform_type\":\"2\",\"language\":\"zh_CN\"}}"); Assert.AreEqual(JsonCreate.TryMatch("weixin"), "{\"user_id\":\"weixin\"}"); Assert.AreEqual(JsonCreate.DelCondition("208379533"), "{\"menuid\":\"208379533\"}"); //Api.Menu.Create(Api.GetAccessToken(Config), new List<Model.MenuBase>() { // new Model.MenuTop("菜单",new List<Model.MenuBase>(){ // new Model.MenuView("搜索","http://www.soso.com/"), // new Model.MenuClick("赞一下我们","V1001_GOOD"), // new Model.MenuLocationSelect("发送位置","rselfmenu_2_0"), // }), // new Model.MenuTop("扫码",new List<Model.MenuBase>(){ // new Model.MenuScanWait("扫码带提示","rselfmenu_0_0"), // new Model.MenuScanPush("扫码推事件","rselfmenu_0_1") // }), // new Model.MenuTop("发图",new List<Model.MenuBase>(){ // new Model.MenuSysPhoto("系统拍照发图","rselfmenu_1_0"), // new Model.MenuPhotoOrAlbum("拍照或者相册发图","rselfmenu_1_1"), // new Model.MenuPicWeixin("微信相册发图","rselfmenu_1_2") // }), //}); //var data = Api.Menu.Get(Api.GetAccessToken(Config)); //data = Api.Menu.GetCurrentSelfMenuInfo(Api.GetAccessToken(Config)); //var condition = Api.Menu.AddCondition(Api.GetAccessToken(Config), new Model.MenuMatchRule() //{ // TagId = 2, // Sex = MenuMatchSex.男, // Country = "中国", // Province = "广东", // City = "广州", // ClientPlatformType = MenuMatchPlatform.Android, // Language = MenuMatchLanguage.简体中文 //}, new List<Model.MenuBase>() { // new Model.MenuClick("今日歌曲","V1001_TODAY_MUSIC"), // new Model.MenuTop("菜单",new List<Model.MenuBase>(){ // new Model.MenuView("搜索","http://www.soso.com/"), // new Model.MenuClick("赞一下我们","V1001_GOOD") // }) //}); //Api.Menu.DelCondition(Api.GetAccessToken(Config), condition); //var match = Api.Menu.TryMatch(Api.GetAccessToken(Config), "oOk2XjhrbcHP3tGgzDGAVHppo3Bs"); //Api.Menu.Delete(Api.GetAccessToken(Config)); }
public static JsonResult Close(string access_token, string kf_account, string openid) => ApiPost <JsonResult>(JsonCreate.Create(kf_account, openid), "/customservice/kfsession/close?access_token={0}", access_token);