示例#1
0
        private string rawOauthRequest(List<QueryParameter> p)
        {
            string response;

            try
            {
                response = (string)_oauthConsumer.request(_baseUrl + _tradeUrl, "POST", p, "PLAIN");
            }
            catch (Exception e)
            {
                // At this stage, this error should occur only if the access token has expired (1 week of inactivity)
                // or has been manually revoked on the API tab of the Account page.
                ChangeAuthStatus(AuthStatusType.AS_NONE);
                if (e.Message.Equals("The remote server returned an error: (401) Unauthorized."))
                {
                    throw (new BTCTAuthException("Unauthorized."));
                }
                else
                {
                    throw (new BTCTException("Unknown error with request. Message: " + e.Message));
                }
            }
            if (response == "Request rate limit exceeded, come back in 60 seconds.\r\n")
            {
                BTCTException tantrum = new BTCTException("Request Error. Message: " + response);

                throw tantrum; // I WANT MY DATA! I WANT IT NOW!
            }
            Debug(response);

            return response;
        }
示例#2
0
        private string rawHttpRequest(string uri)
        {
            string c = String.Empty;

            try
            {
                System.Net.HttpWebRequest request = System.Net.HttpWebRequest.Create(uri) as System.Net.HttpWebRequest;
                request.ProtocolVersion = HttpVersion.Version10;
                using (System.Net.HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse)
                {
                    System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());

                    // BTCT runs on a Unix/Linux system. Need to insert a "proper" Windows linebreak.
                    c = (reader.ReadToEnd()).Replace("\n", Environment.NewLine);
                }
            }
            catch (Exception ex)
            {
                throw (new BTCTException("Network Error. Message: " + ex.Message));
            }
            finally
            {
                GC.Collect();
            }
            if (c.Contains("Request rate limit exceeded, come back in 60 seconds."))
            {
                BTCTException tantrum = new BTCTException("Request Error. Message: " + c);

                throw tantrum; // I WANT MY DATA! I WANT IT NOW!
            }
            Debug(c);

            return c;
        }