public void CreateConditionalMenuTest() { BaseSettings weixinSetting = new BaseSettings() { AppId = "wx6eff55d0d76e210f", AppSecret = "60ab768429e8fc6b86abaa9cfd1c6565" }; OAuthInterfaceCaller oAuthInterface = new OAuthInterfaceCaller(new RestClient(), weixinSetting); ICache cache = new InMemoryCache(new MemoryCache(new MemoryCacheOptions())); AccessTokenContainer container = new AccessTokenContainer(cache, oAuthInterface); var accessToken = container.GetAccessToken(); MenuInterfaceCaller menuInterfaceCaller = new MenuInterfaceCaller(new RestClient()); IConditionalMenu conditionalMenu = new ConditionalMenu(); conditionalMenu.button.Add(new SingleClickButton("Man") { key = "Conditional_Key_Man" }); conditionalMenu.matchrule = new MatchRule() { sex = "1" }; var menuId = menuInterfaceCaller.CreateConditionalMenu(accessToken, conditionalMenu.ToJson()); Console.WriteLine(menuId.menuid); }
public void UnTaggingTest() { ICache cache = new InMemoryCache(new MemoryCache(new MemoryCacheOptions())); BaseSettings weixinSetting = new BaseSettings() { AppId = "wx6eff55d0d76e210f", AppSecret = "60ab768429e8fc6b86abaa9cfd1c6565" }; OAuthInterfaceCaller oAuthInterface = new OAuthInterfaceCaller(new RestClient(), weixinSetting); AccessTokenContainer container = new AccessTokenContainer(cache, oAuthInterface); string accessToken = container.GetAccessToken(); UserTagManageInterfaceCaller tagManageInterfaceCaller = new UserTagManageInterfaceCaller(new RestClient()); Console.WriteLine(tagManageInterfaceCaller.UnTagging(accessToken, 100, "oGV7Kv5pT6m1P5zHDU3sHg4FT1JA")); }
public void GetMenuTest() { BaseSettings weixinSetting = new BaseSettings() { AppId = "wx6eff55d0d76e210f", AppSecret = "60ab768429e8fc6b86abaa9cfd1c6565" }; OAuthInterfaceCaller oAuthInterface = new OAuthInterfaceCaller(new RestClient(), weixinSetting); ICache cache = new InMemoryCache(new MemoryCache(new MemoryCacheOptions())); AccessTokenContainer container = new AccessTokenContainer(cache, oAuthInterface); var accessToken = container.GetAccessToken(); MenuInterfaceCaller menuInterfaceCaller = new MenuInterfaceCaller(new RestClient()); Console.WriteLine(menuInterfaceCaller.GetMenu(accessToken)); }
public void TryMatchConditionalMenuTest() { BaseSettings weixinSetting = new BaseSettings() { AppId = "wx6eff55d0d76e210f", AppSecret = "60ab768429e8fc6b86abaa9cfd1c6565" }; OAuthInterfaceCaller oAuthInterface = new OAuthInterfaceCaller(weixinSetting); ICache cache = new InMemoryCache(new MemoryCache(new MemoryCacheOptions())); AccessTokenContainer container = new AccessTokenContainer(cache, oAuthInterface); var accessToken = container.GetAccessToken(); MenuInterfaceCaller menuInterfaceCaller = new MenuInterfaceCaller(); Console.WriteLine(menuInterfaceCaller.TryMatchConditionalMenu(accessToken, "oGV7Kv0bgXvAUabe8sDopmKlzPNE")); }
public void RemarkTest() { ICache cache = new InMemoryCache(new MemoryCache(new MemoryCacheOptions())); BaseSettings weixinSetting = new BaseSettings() { AppId = "wx6eff55d0d76e210f", AppSecret = "60ab768429e8fc6b86abaa9cfd1c6565" }; OAuthInterfaceCaller oAuthInterface = new OAuthInterfaceCaller(new RestClient(), weixinSetting); AccessTokenContainer container = new AccessTokenContainer(cache, oAuthInterface); string accessToken = container.GetAccessToken(); UserTagManageInterfaceCaller tagManageInterfaceCaller = new UserTagManageInterfaceCaller(new RestClient()); Console.WriteLine(tagManageInterfaceCaller.Remark(accessToken, "oGV7Kv0bgXvAUabe8sDopmKlzPNE", "备注")); }
public void UpdateTagTest() { ICache cache = new InMemoryCache(new MemoryCache(new MemoryCacheOptions())); BaseSettings weixinSetting = new BaseSettings() { AppId = "wx6eff55d0d76e210f", AppSecret = "60ab768429e8fc6b86abaa9cfd1c6565" }; OAuthInterfaceCaller oAuthInterface = new OAuthInterfaceCaller(weixinSetting); AccessTokenContainer container = new AccessTokenContainer(cache, oAuthInterface); string accessToken = container.GetAccessToken(); UserTagManageInterfaceCaller tagManageInterfaceCaller = new UserTagManageInterfaceCaller(); Console.WriteLine(tagManageInterfaceCaller.UpdateTag(accessToken, 100, "新名字")); }
public void GetTagTest() { ICache cache = new InMemoryCache(new MemoryCache(new MemoryCacheOptions())); BaseSettings weixinSetting = new BaseSettings() { AppId = "wx6eff55d0d76e210f", AppSecret = "60ab768429e8fc6b86abaa9cfd1c6565" }; OAuthInterfaceCaller oAuthInterface = new OAuthInterfaceCaller(new RestClient(), weixinSetting); AccessTokenContainer container = new AccessTokenContainer(cache, oAuthInterface); string accessToken = container.GetAccessToken(); UserTagManageInterfaceCaller tagManageInterfaceCaller = new UserTagManageInterfaceCaller(new RestClient()); var tags = tagManageInterfaceCaller.GetTags(accessToken); Console.WriteLine(JsonConvert.SerializeObject(tags)); }
public void UserInfoTest() { ICache cache = new InMemoryCache(new MemoryCache(new MemoryCacheOptions())); BaseSettings weixinSetting = new BaseSettings() { AppId = "wx6eff55d0d76e210f", AppSecret = "60ab768429e8fc6b86abaa9cfd1c6565" }; OAuthInterfaceCaller oAuthInterface = new OAuthInterfaceCaller(new RestClient(), weixinSetting); AccessTokenContainer container = new AccessTokenContainer(cache, oAuthInterface); string accessToken = container.GetAccessToken(); UserTagManageInterfaceCaller tagManageInterfaceCaller = new UserTagManageInterfaceCaller(new RestClient()); var userInfo = tagManageInterfaceCaller.GetUserInfo(accessToken, "oGV7Kv0bgXvAUabe8sDopmKlzPNE", Model.Enums.Language.zh_CN); Console.WriteLine(JsonConvert.SerializeObject(userInfo)); }
public void DeleteConditionalMenuTest() { BaseSettings weixinSetting = new BaseSettings() { AppId = "wx6eff55d0d76e210f", AppSecret = "60ab768429e8fc6b86abaa9cfd1c6565" }; OAuthInterfaceCaller oAuthInterface = new OAuthInterfaceCaller(weixinSetting); ICache cache = new InMemoryCache(new MemoryCache(new MemoryCacheOptions())); AccessTokenContainer container = new AccessTokenContainer(cache, oAuthInterface); var accessToken = container.GetAccessToken(); MenuInterfaceCaller menuInterfaceCaller = new MenuInterfaceCaller(); var menuId = new MenuId() { menuid = "415822427" }; Console.WriteLine(menuInterfaceCaller.DeleteConditionalMenu(accessToken, menuId)); }
public void GetAccessTokenTest() { ICache cache = new InMemoryCache(new MemoryCache(new MemoryCacheOptions())); //ICache cache = new RedisCache(new Microsoft.Extensions.Caching.Redis.RedisCache(new Microsoft.Extensions.Caching.Redis.RedisCacheOptions() { Configuration = "127.0.0.1:6379,password=123456" })); BaseSettings weixinSetting = new BaseSettings() { AppId = "wx6eff55d0d76e210f", AppSecret = "60ab768429e8fc6b86abaa9cfd1c6565" }; OAuthInterfaceCaller oAuthInterface = new OAuthInterfaceCaller(new RestClient(), weixinSetting); var container = new AccessTokenContainer(cache, oAuthInterface); List <string> tokens = new List <string>(); for (int i = 0; i < 10; i++) { tokens.Add(container.GetAccessToken()); } foreach (var item in tokens) { Console.WriteLine(item); } }
public void CreateMenuTest() { BaseSettings weixinSetting = new BaseSettings() { AppId = "wx6eff55d0d76e210f", AppSecret = "60ab768429e8fc6b86abaa9cfd1c6565" }; OAuthInterfaceCaller oAuthInterface = new OAuthInterfaceCaller(new RestClient(), weixinSetting); ICache cache = new InMemoryCache(new MemoryCache(new MemoryCacheOptions())); AccessTokenContainer container = new AccessTokenContainer(cache, oAuthInterface); var accessToken = container.GetAccessToken(); string menu = @" { ""button"":[ { ""type"":""click"", ""name"":""今日歌曲"", ""key"":""V1001_TODAY_MUSIC"" }, { ""name"":""菜单"", ""sub_button"":[ { ""type"":""view"", ""name"":""搜索"", ""url"":""http://www.soso.com/"" }, { ""type"":""click"", ""name"":""赞一下我们"", ""key"":""V1001_GOOD"" }] }] } "; MenuInterfaceCaller menuInterfaceCaller = new MenuInterfaceCaller(new RestClient()); Console.WriteLine(menuInterfaceCaller.CreateMenu(accessToken, menu)); }
public AuthorizationContainer(ICache cache, OAuthInterfaceCaller oAuthInterfaceCaller) { _cache = cache; _oAuthInterfaceCaller = oAuthInterfaceCaller; }
public AccessTokenContainer(ICache cache, OAuthInterfaceCaller oAuthInterfaceCaller) { _cache = cache; _oAuthInterfaceCaller = oAuthInterfaceCaller; }