public string GenerateSignature(Uri url, string consumerKey, string consumerSecret, string token, string tokenSecret, string callBackUrl, string oauthVerifier, string httpMethod, string timeStamp, string nonce, TwitterBase.SignatureTypes signatureType, out string normalizedUrl, out string normalizedRequestParameters)
        {
            string str;

            normalizedUrl = null;
            normalizedRequestParameters = null;
            switch (signatureType)
            {
            case TwitterBase.SignatureTypes.HMACSHA1: {
                string   str1     = this.GenerateSignatureBase(url, consumerKey, token, tokenSecret, callBackUrl, oauthVerifier, httpMethod, timeStamp, nonce, "HMAC-SHA1", out normalizedUrl, out normalizedRequestParameters);
                HMACSHA1 hMACSHA1 = new HMACSHA1()
                {
                    Key = Encoding.ASCII.GetBytes(string.Format("{0}&{1}", TwitterBase.UrlEncode(consumerSecret), (string.IsNullOrEmpty(tokenSecret) ? string.Empty : TwitterBase.UrlEncode(tokenSecret))))
                };
                str = this.GenerateSignatureUsingHash(str1, hMACSHA1);
                break;
            }

            case TwitterBase.SignatureTypes.PLAINTEXT: {
                str = HttpUtility.UrlEncode(string.Format("{0}&{1}", consumerSecret, tokenSecret));
                break;
            }

            case TwitterBase.SignatureTypes.RSASHA1: {
                throw new NotImplementedException();
            }

            default: {
                throw new ArgumentException("Unknown signature type", "signatureType");
            }
            }
            return(str);
        }
        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);
        }
        public string GenerateSignatureBase(Uri url, string consumerKey, string token, string tokenSecret, string callBackUrl, string oauthVerifier, string httpMethod, string timeStamp, string nonce, string signatureType, out string normalizedUrl, out string normalizedRequestParameters)
        {
            bool flag;

            if (token == null)
            {
                token = string.Empty;
            }
            if (tokenSecret == null)
            {
                tokenSecret = string.Empty;
            }
            if (string.IsNullOrEmpty(consumerKey))
            {
                throw new ArgumentNullException("consumerKey");
            }
            if (string.IsNullOrEmpty(httpMethod))
            {
                throw new ArgumentNullException("httpMethod");
            }
            if (string.IsNullOrEmpty(signatureType))
            {
                throw new ArgumentNullException("signatureType");
            }
            normalizedUrl = null;
            normalizedRequestParameters = null;
            List <TwitterBase.QueryParameter> queryParameters = this.GetQueryParameters(url.Query);

            queryParameters.Add(new TwitterBase.QueryParameter("oauth_version", "1.0"));
            queryParameters.Add(new TwitterBase.QueryParameter("oauth_nonce", nonce));
            queryParameters.Add(new TwitterBase.QueryParameter("oauth_timestamp", timeStamp));
            queryParameters.Add(new TwitterBase.QueryParameter("oauth_signature_method", signatureType));
            queryParameters.Add(new TwitterBase.QueryParameter("oauth_consumer_key", consumerKey));
            if (!string.IsNullOrEmpty(callBackUrl))
            {
                queryParameters.Add(new TwitterBase.QueryParameter("oauth_callback", TwitterBase.UrlEncode(callBackUrl)));
            }
            if (!string.IsNullOrEmpty(oauthVerifier))
            {
                queryParameters.Add(new TwitterBase.QueryParameter("oauth_verifier", oauthVerifier));
            }
            if (!string.IsNullOrEmpty(token))
            {
                queryParameters.Add(new TwitterBase.QueryParameter("oauth_token", token));
            }
            queryParameters.Sort(new TwitterBase.QueryParameterComparer());
            normalizedUrl = string.Format("{0}://{1}", url.Scheme, url.Host);
            if (!(url.Scheme == "http") || url.Port != 80)
            {
                flag = (url.Scheme != "https" ? false : url.Port == 443);
            }
            else
            {
                flag = true;
            }
            if (!flag)
            {
                normalizedUrl = string.Concat(normalizedUrl, ":", url.Port);
            }
            normalizedUrl = string.Concat(normalizedUrl, url.AbsolutePath);
            normalizedRequestParameters = this.NormalizeRequestParameters(queryParameters);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat("{0}&", httpMethod.ToUpper());
            stringBuilder.AppendFormat("{0}&", TwitterBase.UrlEncode(normalizedUrl));
            stringBuilder.AppendFormat("{0}", TwitterBase.UrlEncode(normalizedRequestParameters));
            return(stringBuilder.ToString());
        }
        public void Tweet(string content)
        {
            string      empty       = string.Empty;
            string      str         = string.Empty;
            TwitterAuth twitterAuth = new TwitterAuth(TwitterConnect.API_Key, TwitterConnect.API_Secret, this.CallBackUrl);

            if ((this.OAuthToken == null ? false : this.OAuthTokenSecret != null))
            {
                twitterAuth.TokenSecret   = this.OAuthToken;
                twitterAuth.Token         = this.OAuthTokenSecret;
                twitterAuth.OAuthVerifier = HttpContext.Current.Request.QueryString["oauth_verifier"];
            }
            else
            {
                twitterAuth.AccessTokenGet(HttpContext.Current.Request.QueryString["oauth_token"], HttpContext.Current.Request.QueryString["oauth_verifier"]);
                this.OAuthToken       = twitterAuth.TokenSecret;
                this.OAuthTokenSecret = twitterAuth.Token;
            }
            if (twitterAuth.TokenSecret.Length > 0)
            {
                empty = "https://api.twitter.com/1.1/statuses/update.json";
                str   = twitterAuth.OAuthWebRequest(TwitterAuth.Method.POST, empty, string.Concat("status=", TwitterBase.UrlEncode(content)));
            }
        }