Example #1
0
        /*
        private string GenerateSignature(string url, string token, string token_secret, string method,
            out string normalizedUrl, out string normalizedRequestParameters)
        {
            return GenerateSignature(new Uri(url), CONSUMER_KEY, CONSUMER_SECRET,
                token, token_secret, method, GenerateTimeStamp(), GenerateNonce(),
                out normalizedUrl, out normalizedRequestParameters);
        }
         * */
        public void OAuthRequest(string url, string method, string token, string tokenSecret,
            DownloadStringCompletedEventHandler completed)
        {
            string normalizedUrl, normalizedRequestParameters;
            /*
            string hash = GenerateSignature(new Uri(url), CONSUMER_KEY, CONSUMER_SECRET,
                token, tokenSecret, method,
                GenerateTimeStamp(), GenerateNonce(),
                out normalizedUrl, out normalizedRequestParameters);
             * */
            string hash = GenerateSignature(new Uri(url), CONSUMER_KEY, CONSUMER_SECRET,
                token, tokenSecret, method,
                GenerateTimestamp(), GenerateNonce(), out normalizedUrl, out normalizedRequestParameters);

            MyWebClient client = new MyWebClient();

            string signedUrl = normalizedUrl + "?" + normalizedRequestParameters
                + "&" + OAuthSignatureKey + "=" + UrlEncode(hash);

            client.DownloadStringCompleted += completed;
            client.DownloadStringAsync(new Uri(signedUrl));
        }
Example #2
0
        public bool OAuthPost(string url, UploadStringCompletedEventHandler completed,
            string token = null, string tokenSecret = null)
        {
            string method = "POST";
            if (Account == null || string.IsNullOrEmpty(Account.AccessToken) || string.IsNullOrEmpty(Account.AccessTokenSecret))
            {
                return false;
            }
            if (token == null) {
                token = Account.AccessToken;
                tokenSecret = Account.AccessTokenSecret;
            }

            string normalizedUrl, normalizedRequestParameters;
            /*
            string hash = GenerateSignature(new Uri(url), CONSUMER_KEY, CONSUMER_SECRET,
                token, tokenSecret, method,
                GenerateTimestamp(), GenerateNonce(),
                out normalizedUrl, out normalizedRequestParameters);

            string signedUrl = normalizedUrl + "?" + normalizedRequestParameters
                + "&" + OAuthSignatureKey + "=" + UrlEncode(hash);
             * */
            string hash = GenerateSignature(new Uri(url), CONSUMER_KEY, CONSUMER_SECRET,
                token, tokenSecret, method,
                GenerateTimestamp(), GenerateNonce(),
                out normalizedUrl, out normalizedRequestParameters);

            MyWebClient client = new MyWebClient();
            client.UploadStringCompleted += completed;
            client.UploadStringAsync(new Uri(normalizedUrl),
                normalizedRequestParameters
                + "&" + OAuthSignatureKey + "=" + UrlEncode(hash));
            return true;
        }