Ejemplo n.º 1
0
        public async Task <WxUser> GetSnsApiUserInfo(string code)
        {
            var token = await AccessTokenFactory.GetTokenAsync(code);

            if (token == null)
            {
                return(null);
            }

            string url = $"{WxConstants.SNSAPI_USERINFO_URL}?access_token={token.AccessToken}&openid={token.OpenId}&lang=zh_CN";

            return(await WxClient.GetAsync <WxUser>(url));
        }
Ejemplo n.º 2
0
        public override IMigrationProcessor Create(string connectionString, IAnnouncer announcer, IMigrationProcessorOptions options)
        {
            var factory = new SqlServerDbFactory();

            var accessTokenFactory = new AccessTokenFactory(_clientId, _certThumbPrint, StoreLocation.CurrentUser);
            var accessToken        = accessTokenFactory.GetTokenAsync(_authority, "https://database.windows.net/").GetAwaiter().GetResult();

            var connection = new SqlConnection(connectionString)
            {
                AccessToken = accessToken
            };

            return(new SqlServerProcessor(connection, new SqlServer2014Generator(), announcer, options, factory));
        }
Ejemplo n.º 3
0
        public async Task SendTempMsg(string toUser, string tempId, object data, string url = "", string color = null)
        {
            var token = await AccessTokenFactory.GetTokenAsync();

            if (token == null)
            {
                return;
            }

            var msg = new
            {
                touser      = toUser,
                template_id = tempId,
                data,
                url,
                color
            };

            string uri = $"{WxConstants.CGI_BIN_TEMPLATE_URL}?access_token={token.AccessToken}";

            var content = new StringContent(msg.ToJsonString(), System.Text.Encoding.UTF8, "application/json");

            await WxClient.PostAsync(uri, content);
        }