internal string getUrl(RequestData requestData) { byte[] _key = Encoding.ASCII.GetBytes(APISecret); string _sig = encodeJsonToSig(requestData.GetJsonData(), _key); return string.Format("{0}://{1}?sig={2}", (isHTTPS)? "https" : "http", grooveSharkAPI, _sig); }
internal string getResponse(string url, RequestData requestData) { string _retVal = string.Empty; WebRequest _request = WebRequest.Create(url); _request.Method = "POST"; string _data = requestData.GetJsonData(); using (Stream _stream = _request.GetRequestStream()) { _stream.Write(requestData.GetByteArrayData(), 0, requestData.GetByteArrayData().Length); } WebResponse _response = _request.GetResponse(); using (StreamReader _reader = new StreamReader(_response.GetResponseStream())) { _retVal = _reader.ReadToEnd(); } if (OnRequestRespondedEvent != null) OnRequestRespondedEvent(_retVal); XDocument _doc = JsonConvert.DeserializeXNode(_retVal, "response"); var _errorElem = _doc.Element("response").Element("errors"); if (_errorElem != null) throw new GrooveException(_errorElem); return _retVal; }