Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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"));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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"));
        }
Esempio n. 5
0
        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", "备注"));
        }
Esempio n. 6
0
        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, "新名字"));
        }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        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));
        }
Esempio n. 9
0
        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));
        }
Esempio n. 10
0
        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);
            }
        }
Esempio n. 11
0
        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));
        }
Esempio n. 12
0
 public AuthorizationContainer(ICache cache, OAuthInterfaceCaller oAuthInterfaceCaller)
 {
     _cache = cache;
     _oAuthInterfaceCaller = oAuthInterfaceCaller;
 }
Esempio n. 13
0
 public AccessTokenContainer(ICache cache, OAuthInterfaceCaller oAuthInterfaceCaller)
 {
     _cache = cache;
     _oAuthInterfaceCaller = oAuthInterfaceCaller;
 }