private JObject Post(Dictionary<string, string> _params) { string _data = ""; foreach (KeyValuePair<string, string> _param in _params) { _data += _data == "" ? "" : "&"; _data += _param.Key + "=" + _param.Value; } _data = "access_key=" + this.key + "&" + _data; string _sign = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(_data + "&secret_key=" + this.secret, "MD5").ToLower(); _data += "&sign=" + _sign; WebClientPlus _webClient = new WebClientPlus(this.timeout); _webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); string _result = _webClient.UploadString(this.url, _data); _webClient.Dispose(); if (_result[0] == '[') { _result = "{\"list\":" + _result + "}"; } JObject _json = JObject.Parse(_result); if (_json.GetValue("code") != null) { throw new HuobiException(_json.GetValue("code").Value<string>(), _json.GetValue("msg").Value<string>()); } return _json; }
private static string Get(string _url, int _timeout = 5000) { WebClientPlus _webClient = new WebClientPlus(_timeout); string _result = _webClient.DownloadString(_url); _webClient.Dispose(); return _result; }