/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <param name="callback"></param> public void GetResponse(HttpMethodName methodName, String url, String token, String tokenSecret , IDictionary<String, String> queryString, Action<HttpResponse> callback) { HttpClient cl = this; var cm = this.CreateHttpRequestCommand(methodName, url, token, tokenSecret, queryString); cl.GetResponse(cm, callback); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <param name="parameters"></param> /// <param name="callback"></param> public void GetResponse(HttpMethodName methodName, String url, String token, String tokenSecret , IDictionary<String, String> queryString, IDictionary<String, String> parameters, Action<HttpResponse> callback) { Dictionary<String, String> d = null; HttpClient cl = this.CreateHttpClient(methodName, url, token, tokenSecret, queryString); if (parameters != null) { d = new Dictionary<string, string>(); foreach (KeyValuePair<string, string> p in parameters) { d[p.Key] = cl.UrlEncodeFunction(p.Value); } } cl.GetResponse(d, callback); }
/// <summary> /// /// </summary> /// <param name="consumerKey"></param> /// <param name="consumerKeySecret"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="methodName"></param> public GetRequestTokenCommand(String consumerKey, String consumerKeySecret, String token, String tokenSecret , HttpMethodName methodName) { if (String.IsNullOrEmpty(consumerKey) == true){throw new ArgumentNullException("consumerKey");} this.ConsumerKey = consumerKey; this.ConsumerKeySecret = consumerKeySecret; this.Token = token; this.TokenSecret = tokenSecret; this.MethodName = methodName; this.Nonce = OAuth1Client.GenerateNonce(); this.TimeStamp = OAuth1Client.GenerateTimeStamp(); if (this.Token == null) { this.Token = String.Empty; } }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <param name="parameters"></param> /// <param name="callback"></param> public void GetHttpWebResponse(HttpMethodName methodName, String url, String token, String tokenSecret , IDictionary<String, String> queryString, IDictionary<String, String> parameters, Action<HttpWebResponse> callback) { Dictionary<String, String> d = null; var cm = this.CreateHttpRequestCommand(methodName, url, token, tokenSecret, queryString); if (parameters != null) { d = new Dictionary<string, string>(); cm.ContentType = HttpClient.ApplicationFormUrlEncoded; foreach (var p in parameters) { d[p.Key] = cm.UrlEncodeFunction(p.Value); } } cm.SetBodyStream(new HttpBodyFormUrlEncodedData(Encoding.UTF8, d)); this.GetHttpWebResponse(cm, callback); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <param name="parameters"></param> /// <param name="callback"></param> public void GetHttpWebResponse(HttpMethodName methodName, String url, String token, String tokenSecret , IDictionary <String, String> queryString, IDictionary <String, String> parameters, Action <HttpWebResponse> callback) { Dictionary <String, String> d = null; var cm = this.CreateHttpRequestCommand(methodName, url, token, tokenSecret, queryString); if (parameters != null) { d = new Dictionary <string, string>(); cm.ContentType = HttpClient.ApplicationFormUrlEncoded; foreach (var p in parameters) { d[p.Key] = cm.UrlEncodeFunction(p.Value); } } cm.SetBodyStream(this.RequestEncoding, d); this.GetHttpWebResponse(cm, callback); }
private HttpRequestCommand CreateHttpClientQueryStringMode(HttpMethodName methodName, String url, String token, String tokenSecret, IDictionary <String, String> queryString) { var cm = new GetRequestTokenCommand(this.ConsumerKey, this.ConsumerSecret, token, tokenSecret, methodName); Dictionary <String, String> pp = OAuth1Client.GenerateParameters(cm); foreach (var p in queryString) { pp.Add(p.Key, p.Value); } var u = new Uri(HttpClient.CreateQueryString(url, pp, OAuth1Client.UrlEncode)); SignatureInfo si = GenerateSignature(u, cm); pp.Add("oauth_signature", OAuth1Client.UrlEncode(si.Signature)); HttpRequestCommand cl = new HttpRequestCommand(HttpClient.CreateQueryString(url, pp, HttpClient.UrlEncode)); cl.MethodName = methodName; return(cl); }
/// <summary> /// /// </summary> /// <param name="consumerKey"></param> /// <param name="consumerKeySecret"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="methodName"></param> public GetRequestTokenCommand(String consumerKey, String consumerKeySecret, String token, String tokenSecret , HttpMethodName methodName) { if (String.IsNullOrEmpty(consumerKey) == true) { throw new ArgumentNullException("consumerKey"); } this.ConsumerKey = consumerKey; this.ConsumerKeySecret = consumerKeySecret; this.Token = token; this.TokenSecret = tokenSecret; this.MethodName = methodName; this.Nonce = OAuthClient.GenerateNonce(); this.TimeStamp = OAuthClient.GenerateTimeStamp(); if (this.Token == null) { this.Token = String.Empty; } }
private HttpClient CreateHttpClientQueryStringMode(HttpMethodName methodName, String url, String token, String tokenSecret, IEnumerable <KeyValuePair <string, string> > queryString) { String timeStamp = OAuthClient.GenerateTimeStamp(); String nonce = OAuthClient.GenerateNonce(); Dictionary <String, String> pp = OAuthClient.GenerateParameters(ConsumerKey, token, timeStamp, nonce); foreach (KeyValuePair <string, string> p in queryString) { pp.Add(p.Key, p.Value); } //NOTE:NET2.0 Uri u = new Uri(HttpClient.CreateQueryString(url, pp, OAuthClient.UrlEncode)); SignatureInfo si = GenerateSignature(u, this.ConsumerKey, this.ConsumerSecret, token, tokenSecret , methodName.ToString().ToUpper(), timeStamp, nonce); pp.Add("oauth_signature", OAuthClient.UrlEncode(si.Signature)); //NOTE:NET2.0 HttpClient cl = new HttpClient(HttpClient.CreateQueryString(url, pp, HttpClient.UrlEncode)); cl.MethodName = methodName; return(cl); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <returns></returns> public HttpWebResponse GetHttpWebResponse(HttpMethodName methodName, String url, String token, String tokenSecret , IDictionary<String, String> queryString) { return this.GetHttpWebResponse(methodName, url, token, tokenSecret, queryString, new Dictionary<String, String>()); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="bodyData"></param> /// <returns></returns> public HttpResponse GetResponse(HttpMethodName methodName, String url, String token, String tokenSecret , Byte[] bodyData) { HttpClient cl = this.CreateHttpClient(methodName, url, token, tokenSecret, new Dictionary<String, String>()); return cl.GetResponse(bodyData); }
private HttpClient CreateHttpClientRequestHeaderMode(HttpMethodName methodName, String url, String token, String tokenSecret, IDictionary<String, String> queryString) { String timeStamp = OAuthClient.GenerateTimeStamp(); String nonce = OAuthClient.GenerateNonce(); Dictionary<String, String> pp = OAuthClient.GenerateParameters(ConsumerKey, token, timeStamp, nonce); Uri u = new Uri(HttpClient.CreateQueryString(url, queryString, OAuthClient.UrlEncode)); SignatureInfo si = GenerateSignature(u, this.ConsumerKey, this.ConsumerSecret, token, tokenSecret , methodName.ToString().ToUpper(), timeStamp, nonce); pp.Add("oauth_signature", OAuthClient.UrlEncode(si.Signature)); //NOTE:NET2.0 HttpClient cl = new HttpClient(HttpClient.CreateQueryString(url, queryString, HttpClient.UrlEncode)); cl.MethodName = methodName; cl.Headers[HttpRequestHeader.Authorization] = this.CreateOAuthHeader(pp); return cl; }
private HttpClient CreateHttpClientQueryStringMode(HttpMethodName methodName, String url, String token, String tokenSecret, IEnumerable<KeyValuePair<string, string>> queryString) { String timeStamp = OAuthClient.GenerateTimeStamp(); String nonce = OAuthClient.GenerateNonce(); Dictionary<String, String> pp = OAuthClient.GenerateParameters(ConsumerKey, token, timeStamp, nonce); foreach (KeyValuePair<string, string> p in queryString) { pp.Add(p.Key, p.Value); } //NOTE:NET2.0 Uri u = new Uri(HttpClient.CreateQueryString(url, pp, OAuthClient.UrlEncode)); SignatureInfo si = GenerateSignature(u, this.ConsumerKey, this.ConsumerSecret, token, tokenSecret , methodName.ToString().ToUpper(), timeStamp, nonce); pp.Add("oauth_signature", OAuthClient.UrlEncode(si.Signature)); //NOTE:NET2.0 HttpClient cl = new HttpClient(HttpClient.CreateQueryString(url, pp, HttpClient.UrlEncode)); cl.MethodName = methodName; return cl; }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="bodyData"></param> /// <param name="callback"></param> public void GetResponse(HttpMethodName methodName, String url, String token, String tokenSecret , Byte[] bodyData, Action<HttpResponse> callback) { var cm = this.CreateHttpRequestCommand(methodName, url, token, tokenSecret, new Dictionary<String, String>()); cm.SetBodyStream(bodyData); this.GetResponse(cm, callback); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="bodyData"></param> /// <param name="callback"></param> public void GetResponse(HttpMethodName methodName, String url, String token, String tokenSecret , Byte[] bodyData, Action<HttpResponse> callback) { HttpClient cl = this.CreateHttpClient(methodName, url, token, tokenSecret, new Dictionary<String, String>()); cl.GetResponse(bodyData, callback); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <returns></returns> public HttpResponse GetResponse(HttpMethodName methodName, String url, String token, String tokenSecret , IDictionary<String, String> queryString) { HttpClient cl = this.CreateHttpClient(methodName, url, token, tokenSecret, queryString); return cl.GetResponse(); }
private HttpRequestCommand CreateHttpClientRequestHeaderMode(HttpMethodName methodName, String url, String token, String tokenSecret, IDictionary<String, String> queryString) { var cm = new GetRequestTokenCommand(this.ConsumerKey, this.ConsumerSecret, token, tokenSecret, methodName); Dictionary<String, String> pp = OAuth1Client.GenerateParameters(cm); var u = new Uri(HttpClient.CreateQueryString(url, queryString, OAuth1Client.UrlEncode)); SignatureInfo si = GenerateSignature(u, cm); pp.Add("oauth_signature", OAuth1Client.UrlEncode(si.Signature)); HttpRequestCommand cl = new HttpRequestCommand(HttpClient.CreateQueryString(url, queryString, HttpClient.UrlEncode)); cl.MethodName = methodName; cl.Headers[HttpRequestHeader.Authorization] = this.CreateOAuthHeader(pp); return cl; }
/// <summary> /// WARNING: This plugin's Firebase request implementations are using X-HTTP-Method-Override by default. /// Only use this method to create a custom request or re-override Http Method at your own risk. /// For details see https://firebase.google.com/docs/reference/rest/database/ /// </summary> public FirebaseParam HttpMethodOverride(HttpMethodName methodName) { return(AddHttpHeader("X-HTTP-Method-Override", methodName.ToString())); }
private HttpRequestCommand CreateHttpClientQueryStringMode(HttpMethodName methodName, String url, String token, String tokenSecret, IDictionary<String, String> queryString) { var cm = new GetRequestTokenCommand(this.ConsumerKey, this.ConsumerSecret, token, tokenSecret, methodName); Dictionary<String, String> pp = OAuth1Client.GenerateParameters(cm); foreach (var p in queryString) { pp.Add(p.Key, p.Value); } var u = new Uri(HttpClient.CreateQueryString(url, pp, OAuth1Client.UrlEncode)); SignatureInfo si = GenerateSignature(u, cm); pp.Add("oauth_signature", OAuth1Client.UrlEncode(si.Signature)); HttpRequestCommand cl = new HttpRequestCommand(HttpClient.CreateQueryString(url, pp, HttpClient.UrlEncode)); cl.MethodName = methodName; return cl; }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <returns></returns> public HttpRequestCommand CreateHttpRequestCommand(HttpMethodName methodName, String url, String token, String tokenSecret, IDictionary<String, String> queryString) { HttpRequestCommand cm = null; switch (this.Mode) { case OAuthMode.QueryString: cm = this.CreateHttpClientQueryStringMode(methodName, url, token, tokenSecret, queryString); break; case OAuthMode.Header: cm = this.CreateHttpClientRequestHeaderMode(methodName, url, token, tokenSecret, queryString); break; default: throw new InvalidOperationException(); } return cm; }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <returns></returns> public HttpRequestCommand CreateHttpRequestCommand(HttpMethodName methodName, String url, String token, String tokenSecret) { return this.CreateHttpRequestCommand(methodName, url, token, tokenSecret, new Dictionary<String, String>()); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <param name="parameters"></param> /// <returns></returns> public HttpWebResponse GetHttpWebResponse(HttpMethodName methodName, String url, String token, String tokenSecret , IDictionary<String, String> queryString, IDictionary<String, String> parameters) { Dictionary<String, String> d = new Dictionary<string, string>(); HttpClient cl = this.CreateHttpClient(methodName, url, token, tokenSecret, queryString); foreach (KeyValuePair<string, string> p in parameters) { d[p.Key] = cl.UrlEncodeFunction(p.Value); } return cl.GetHttpWebResponse(d); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <param name="callback"></param> public void GetHttpWebResponse(HttpMethodName methodName, String url, String token, String tokenSecret , IDictionary <String, String> queryString, Action <HttpWebResponse> callback) { this.GetHttpWebResponse(methodName, url, token, tokenSecret, queryString, null, callback); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <returns></returns> public HttpResponse GetResponse(HttpMethodName methodName, String url, String token, String tokenSecret) { return this.GetResponse(methodName, url, token, tokenSecret, new Dictionary<String, String>()); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <returns></returns> public HttpWebResponse GetHttpWebResponse(HttpMethodName methodName, String url, String token, String tokenSecret , IDictionary <String, String> queryString) { return(this.GetHttpWebResponse(methodName, url, token, tokenSecret, queryString, new Dictionary <String, String>())); }
/// <summary> /// /// </summary> /// <param name="url"></param> /// <param name="methodName"></param> public HttpRequestCommand(String url, HttpMethodName methodName) { this.InitializeProperty(); this.Url = url; this.MethodName = methodName; }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <returns></returns> public HttpClient CreateHttpClient(HttpMethodName methodName, String url, String token, String tokenSecret) { return(this.CreateHttpClient(methodName, url, token, tokenSecret, new Dictionary <String, String>())); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <returns></returns> public HttpRequestCommand CreateHttpRequestCommand(HttpMethodName methodName, String url, String token, String tokenSecret) { return(this.CreateHttpRequestCommand(methodName, url, token, tokenSecret, new Dictionary <String, String>())); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <param name="callback"></param> public void GetHttpWebResponse(HttpMethodName methodName, String url, String token, String tokenSecret , IDictionary<String, String> queryString, Action<HttpWebResponse> callback) { this.GetHttpWebResponse(methodName, url, token, tokenSecret, queryString, null, callback); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="callback"></param> public void GetResponse(HttpMethodName methodName, String url, String token, String tokenSecret, Action <HttpResponse> callback) { HttpClient cl = this.CreateHttpClient(methodName, url, token, tokenSecret, new Dictionary <String, String>()); cl.GetResponse(callback); }
public HttpRequestCommand(String url, HttpMethodName methodName) { this.InitializeProperty(); this.Url = url; this.MethodName = methodName; }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <returns></returns> public HttpClient CreateHttpClient(HttpMethodName methodName, String url, String token, String tokenSecret) { return this.CreateHttpClient(methodName, url, token, tokenSecret, new Dictionary<String, String>()); }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <param name="queryString"></param> /// <returns></returns> public HttpClient CreateHttpClient(HttpMethodName methodName, String url, String token, String tokenSecret, IDictionary<String, String> queryString) { HttpClient cl; switch (this.Mode) { case OAuthMode.QueryString: cl = this.CreateHttpClientQueryStringMode(methodName, url, token, tokenSecret, queryString); break; case OAuthMode.Header: cl = this.CreateHttpClientRequestHeaderMode(methodName, url, token, tokenSecret, queryString); break; default: throw new InvalidOperationException(); } this.SetHttpClientProperty(cl); return cl; }
/// <summary> /// /// </summary> /// <param name="methodName"></param> /// <param name="url"></param> /// <param name="token"></param> /// <param name="tokenSecret"></param> /// <returns></returns> public HttpResponse GetResponse(HttpMethodName methodName, String url, String token, String tokenSecret) { return(this.GetResponse(methodName, url, token, tokenSecret, new Dictionary <String, String>())); }
public void SetHttpMethod(HttpMethodName httpMethod) { _httpMethod = httpMethod; }