Esempio n. 1
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);
        }
Esempio n. 2
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);
        }