Beispiel #1
0
        static JObject Get(string url, int timeout = 5000)
        {
            WebClientPlus webClient = new WebClientPlus(timeout);

            string result = webClient.DownloadString(url);

            webClient.Dispose();

            JObject json = JObject.Parse(result);

            return(json);
        }
Beispiel #2
0
        JObject Post(string url, Dictionary <string, string> paramList)
        {
            string data = "";

            Dictionary <string, string> sortParamList = (from entry in paramList orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);

            foreach (KeyValuePair <string, string> param in sortParamList)
            {
                data += data == "" ? "" : "&";
                data += param.Key + "=" + param.Value;
            }

            string sign = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(data + "&secret_key=" + this.api_secret, "MD5").ToUpper();

            data += "&sign=" + sign;

            WebClientPlus webClient = new WebClientPlus(this.timeout);

            webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            string result = webClient.UploadString(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);
        }