예제 #1
0
        public virtual WebRequest CreateKeyRequest(Cryptor cryptor, string method, string input)
        {
            string address = KEY_API;

            if (includeParametersInRequestAddress)
            {
                address += input;
            }

            WebRequest webRequest = (HttpWebRequest)System.Net.WebRequest.Create(address);

            webRequest.Method      = method;
            webRequest.Timeout     = 60000;
            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest             = AddKeyHeaders(cryptor, webRequest);

            byte[] inputBytes = Encoding.UTF8.GetBytes(input);

            webRequest.ContentLength = input.Length;
            using (var dataStream = webRequest.GetRequestStream())
            {
                dataStream.Write(inputBytes, 0, input.Length);
            }

            return(webRequest);
        }
예제 #2
0
        public virtual string DoKeyRequest(string parameters)
        {
            Cryptor cryptor = new Cryptor();

            cryptor.CalcSign(secret, signBaseUrl + parameters);
            WebRequest webRequest = CreateKeyRequest(cryptor, keyMethod, parameters);

            return(GetResponseForRequest(webRequest));
        }
예제 #3
0
파일: Yobit.cs 프로젝트: SuffArt/BitWhiskey
        public string DoKeyRequest(string parameters)
        {
            Cryptor cryptor = new Cryptor();

            cryptor.CalcSign(secret, parameters);
            WebRequest webRequest = CreateKeyRequest(cryptor, parameters);

            return(GetResponseForRequest(webRequest));
        }
예제 #4
0
파일: Yobit.cs 프로젝트: SuffArt/BitWhiskey
        public WebRequest CreateKeyRequest(Cryptor cryptor, string input)
        {
            string address = KEY_API + "?" + input;

            WebRequest webRequest = (HttpWebRequest)System.Net.WebRequest.Create(address);

            webRequest.Method      = "POST";
            webRequest.Timeout     = 20000;
            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.Headers.Add("Key", key);
            webRequest.Headers.Add("Sign", cryptor.sign);

            byte[] inputBytes = Encoding.UTF8.GetBytes(input);

            webRequest.ContentLength = input.Length;
            using (var dataStream = webRequest.GetRequestStream())
            {
                dataStream.Write(inputBytes, 0, input.Length);
            }

            return(webRequest);
        }
예제 #5
0
 public abstract WebRequest AddKeyHeaders(Cryptor cryptor, WebRequest webRequest);
예제 #6
0
 public override WebRequest AddKeyHeaders(Cryptor cryptor, WebRequest webRequest)
 {
     webRequest.Headers.Add("apisign", cryptor.sign);
     return(webRequest);
 }