예제 #1
0
파일: API.cs 프로젝트: Yecats/GW2Helper
        /// <summary>
        /// Gets the list of token information for the account
        /// </summary>
        /// <param name="key">Accuont API Key</param>
        /// <returns></returns>
        public TokenInfo GetTokenInfo(string key)
        {
            TokenInfo tokenInfo = new TokenInfo();
            var client = new HttpClient();
            var request = new HttpRequestMessage()
            {
                RequestUri = new Uri(_tokenInfo + "?access_token=" + key),
                Method = HttpMethod.Get
            };

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain"));

            var task = client.SendAsync(request).ContinueWith((taskwithmsg) =>
            {
                var response = taskwithmsg.Result;
                var jsonTask = response.Content.ReadAsStringAsync();
                tokenInfo = JsonConvert.DeserializeObject<TokenInfo>(jsonTask.Result);
            });
            task.Wait();

            return tokenInfo;
        }
예제 #2
0
파일: General.cs 프로젝트: Yecats/GW2Helper
        public bool ValidateAPIKey()
        {
            _accountInformation = API.Instance.GetAccount(APIKey);
            _tokenInformation = API.Instance.GetTokenInfo(APIKey);

            return true;
        }