private TextReader DoRawRequest( string verb, string entity, Dictionary <string, string> urlArgs, Dictionary <string, string> postArgs) { string urlBase = null; if ((new string[] { "/oauth/request_token", "/oauth/access_token" } as IList).Contains(verb)) { urlBase = _apiUrl + verb; } else { if (entity != null) { urlBase = _apiUrl + verb + "/" + entity; } else { urlBase = _apiUrl + "/" + verb; } } String url; Dictionary <string, string> args = null; if (urlArgs != null) { args = urlArgs; url = urlBase + "?" + Utility.UrlEncodeArgs(urlArgs); } else { url = urlBase; } WebRequest request = WebRequest.Create(url); if (postArgs != null) { args = postArgs; request.Method = "POST"; } else { request.Method = "GET"; } _credential.Authorize(request, _apiUrl, urlBase, args); if (postArgs != null) { // Add postArgs as request's post data. // Must happen after Authorize because we can't write a // request body before adding the Authorization header. request.ContentType = "application/x-www-form-urlencoded"; byte[] data = Encoding.UTF8.GetBytes( Utility.UrlEncodeArgs(postArgs)); request.ContentLength = data.Length; Stream requestStream = request.GetRequestStream(); requestStream.Write(data, 0, data.Length); requestStream.Close(); } WebResponse response = request.GetResponse(); return(new StreamReader(response.GetResponseStream(), Encoding.UTF8)); }