public string WebRequest(TwitterAuth.Method method, string url, string postData) { HttpWebRequest httpWebRequest = null; StreamWriter streamWriter = null; string result = string.Empty; httpWebRequest = (System.Net.WebRequest.Create(url) as HttpWebRequest); httpWebRequest.Method = method.ToString(); httpWebRequest.ServicePoint.Expect100Continue = false; if (method == TwitterAuth.Method.POST || method == TwitterAuth.Method.DELETE) { httpWebRequest.ContentType = "application/x-www-form-urlencoded"; streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()); try { streamWriter.Write(postData); } catch { throw; } finally { streamWriter.Close(); streamWriter = null; } } result = this.WebResponseGet(httpWebRequest); httpWebRequest = null; return(result); }
public string WebRequest(TwitterAuth.Method method, string url, string postData) { HttpWebRequest str = null; StreamWriter streamWriter = null; string empty = string.Empty; str = System.Net.WebRequest.Create(url) as HttpWebRequest; str.Method = method.ToString(); str.ServicePoint.Expect100Continue = false; if ((method == TwitterAuth.Method.POST ? true : method == TwitterAuth.Method.DELETE)) { str.ContentType = "application/x-www-form-urlencoded"; streamWriter = new StreamWriter(str.GetRequestStream()); try { try { streamWriter.Write(postData); } catch { throw; } } finally { streamWriter.Close(); streamWriter = null; } } empty = this.WebResponseGet(str); str = null; return(empty); }
public string OAuthWebRequest(TwitterAuth.Method method, string url, string postData) { string str = string.Empty; string text = string.Empty; string empty = string.Empty; if (method == TwitterAuth.Method.POST || method == TwitterAuth.Method.DELETE || method == TwitterAuth.Method.GET) { if (postData.Length > 0) { NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(postData); postData = string.Empty; string[] allKeys = nameValueCollection.AllKeys; for (int i = 0; i < allKeys.Length; i++) { string text2 = allKeys[i]; if (postData.Length > 0) { postData += "&"; } nameValueCollection[text2] = HttpUtility.UrlDecode(nameValueCollection[text2]); nameValueCollection[text2] = TwitterBase.UrlEncode(nameValueCollection[text2]); postData = postData + text2 + "=" + nameValueCollection[text2]; } if (url.IndexOf("?") > 0) { url += "&"; } else { url += "?"; } url += postData; } } Uri url2 = new Uri(url); string nonce = this.GenerateNonce(); string timeStamp = this.GenerateTimeStamp(); string value = base.GenerateSignature(url2, this.ConsumerKey, this.ConsumerSecret, this.Token, this.TokenSecret, this.CallBackUrl, this.OAuthVerifier, method.ToString(), timeStamp, nonce, out str, out text); text = text + "&oauth_signature=" + TwitterBase.UrlEncode(value); if (method == TwitterAuth.Method.POST || method == TwitterAuth.Method.DELETE) { postData = text; text = string.Empty; } if (text.Length > 0) { str += "?"; } return(this.WebRequest(method, str + text, postData)); }
public string OAuthWebRequest(TwitterAuth.Method method, string url, string postData) { string empty = string.Empty; string str = string.Empty; string empty1 = string.Empty; if ((method == TwitterAuth.Method.POST || method == TwitterAuth.Method.DELETE ? true : method == TwitterAuth.Method.GET)) { if (postData.Length > 0) { NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(postData); postData = string.Empty; string[] allKeys = nameValueCollection.AllKeys; for (int i = 0; i < (int)allKeys.Length; i++) { string str1 = allKeys[i]; if (postData.Length > 0) { postData = string.Concat(postData, "&"); } nameValueCollection[str1] = HttpUtility.UrlDecode(nameValueCollection[str1]); nameValueCollection[str1] = TwitterBase.UrlEncode(nameValueCollection[str1]); postData = string.Concat(postData, str1, "=", nameValueCollection[str1]); } if (url.IndexOf("?") <= 0) { url = string.Concat(url, "?"); } else { url = string.Concat(url, "&"); } url = string.Concat(url, postData); } } Uri uri = new Uri(url); string str2 = this.GenerateNonce(); string str3 = this.GenerateTimeStamp(); string str4 = base.GenerateSignature(uri, this.ConsumerKey, this.ConsumerSecret, this.Token, this.TokenSecret, this.CallBackUrl, this.OAuthVerifier, method.ToString(), str3, str2, out empty, out str); str = string.Concat(str, "&oauth_signature=", TwitterBase.UrlEncode(str4)); if ((method == TwitterAuth.Method.POST ? true : method == TwitterAuth.Method.DELETE)) { postData = str; str = string.Empty; } if (str.Length > 0) { empty = string.Concat(empty, "?"); } empty1 = this.WebRequest(method, string.Concat(empty, str), postData); return(empty1); }