/// <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);
        }
Beispiel #6
0
        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;
     }
 }
Beispiel #8
0
        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);
 }
Beispiel #11
0
 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;
 }
Beispiel #12
0
 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();
 }
Beispiel #16
0
 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;
 }
Beispiel #17
0
 /// <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()));
 }
Beispiel #18
0
 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;
 }
Beispiel #19
0
 /// <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;
 }
Beispiel #20
0
 /// <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>()));
 }
Beispiel #25
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="url"></param>
 /// <param name="methodName"></param>
 public HttpRequestCommand(String url, HttpMethodName methodName)
 {
     this.InitializeProperty();
     this.Url = url;
     this.MethodName = methodName;
 }
Beispiel #26
0
 /// <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>()));
 }
Beispiel #27
0
 /// <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);
        }
Beispiel #30
0
 public HttpRequestCommand(String url, HttpMethodName methodName)
 {
     this.InitializeProperty();
     this.Url        = url;
     this.MethodName = methodName;
 }
Beispiel #31
0
 /// <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>());
 }
Beispiel #32
0
 /// <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>()));
 }
Beispiel #34
0
 public void SetHttpMethod(HttpMethodName httpMethod)
 {
     _httpMethod = httpMethod;
 }