コード例 #1
0
        private async Task <string> RequestAsync(ApiRequestParameters parameters)
        {
            var requestUrl = $"http://alidns.aliyuncs.com/?{parameters.GenerateSortedQueryString()}";

            try
            {
                using (var request = new HttpRequestMessage(HttpMethod.Get, requestUrl))
                {
                    var result = await _httpClient.SendAsync(request);

                    string requestContent = await result.Content.ReadAsStringAsync();

                    if (string.IsNullOrEmpty(requestContent))
                    {
                        ConsoleHelper.WriteError($"远程请求出错:{request.ToString()}");
                    }
                    return(requestContent);
                }
            }
            catch (Exception ex)
            {
                ConsoleHelper.WriteError($"阿里云API请求出错,错误原因为:\r\n{ex.Message}");
                return("");
            }
        }
コード例 #2
0
        private async Task <string> RequestAsync(ApiRequestParameters parameters)
        {
            var requestUrl = $"http://alidns.aliyuncs.com/?{parameters.GenerateSortedQueryString()}";

            using (var request = new HttpRequestMessage(HttpMethod.Get, requestUrl))
            {
                var result = await _httpClient.SendAsync(request);

                return(await result.Content.ReadAsStringAsync());
            }
        }
コード例 #3
0
        private async Task <string> RequestAsync(ApiRequestParameters parameters)
        {
            var requestUrl = $"http://alidns.aliyuncs.com/?{parameters.GenerateSortedQueryString()}";

            using (var request = new HttpRequestMessage(HttpMethod.Get, requestUrl))
            {
                var result = await _httpClient.SendAsync(request);

                string requestContent = await result.Content.ReadAsStringAsync();

                if (string.IsNullOrEmpty(requestContent))
                {
                    AliCloudDynamicDNS.Utility.ConsoleHelper.WriteError($"远程请求出错:{request.ToString()}");
                }
                return(requestContent);
            }
        }