Exemplo n.º 1
0
        public WeixinMpApiTest()
        {
            WeixinServiceRegister.Register()
            .AddMpService();

            string appId     = "wxa60caa8a4543d3fa";
            string appSecret = "4f141b47bca5755a169d46584982186a";

            WeixinMpApiContainer.Register(new MPAccount()
            {
                AppId     = appId,
                AppSecret = appSecret,
            });

            MpApi = WeixinMpApiContainer.GetInstance("default");

            Console.WriteLine(MpApi.Token?.AccessToken);
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            WeixinServiceRegister.Register()
            .AddLogger <WeixinApiLogger>()
            .AddMpService();

            WeixinMpApiContainer.Register(new MPAccount()
            {
                AppId     = Configuration.GetValue <string>("WeiXinMp:AppID"),
                AppSecret = Configuration.GetValue <string>("WeiXinMp:AppSecret"),
                Token     = Configuration.GetValue <string>("WeiXinMp:Token"),
            });

            services.AddSingleton((s) => WeixinMpApiContainer.GetInstance("default"));
            services.AddSingleton <IBizMessageCryptService, BizMessageCryptService>();
        }