public async Task <string> ExecuteAsync(Uri requestUri, TwitterOAuthTokens tokens)
        {
            var request  = CreateRequest(requestUri, tokens);
            var response = await request.GetResponseAsync();

            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
            {
                return(sr.ReadToEnd());
            }
        }
예제 #2
0
        private static WebRequest CreateRequest(Uri requestUri, TwitterOAuthTokens tokens)
        {
            var requestBuilder = new OAuthRequestBuilder(requestUri, tokens);

            var request = (HttpWebRequest)WebRequest.Create(requestBuilder.EncodedRequestUri);

            request.UseDefaultCredentials = true;
            request.Method = OAuthRequestBuilder.Verb;
            request.Headers["Authorization"] = requestBuilder.AuthorizationHeader;

            return(request);
        }
예제 #3
0
        public async Task <string> ExecuteAsync(Uri requestUri, TwitterOAuthTokens tokens)
        {
            string result   = string.Empty;
            var    request  = CreateRequest(requestUri, tokens);
            var    response = await request.GetResponseAsync();

            var responseStream = GetResponseStream(response);

            using (StreamReader sr = new StreamReader(responseStream))
            {
                result = sr.ReadToEnd();
            }
            return(result);
        }
예제 #4
0
        public OAuthRequestBuilder(Uri requestUri, TwitterOAuthTokens tokens)
        {
            RequestUriWithoutQuery = new Uri(requestUri.AbsoluteWithoutQuery());

            QueryParams = requestUri.GetQueryParams()
                          .Select(p => new OAuthParameter(p.Key, p.Value))
                          .ToList();

            EncodedRequestUri = GetEncodedUri(requestUri, QueryParams);

            Version         = new OAuthParameter("oauth_version", "1.0");
            Nonce           = new OAuthParameter("oauth_nonce", GenerateNonce());
            Timestamp       = new OAuthParameter("oauth_timestamp", GenerateTimeStamp());
            SignatureMethod = new OAuthParameter("oauth_signature_method", "HMAC-SHA1");
            ConsumerKey     = new OAuthParameter("oauth_consumer_key", tokens.ConsumerKey);
            ConsumerSecret  = new OAuthParameter("oauth_consumer_secret", tokens.ConsumerSecret);
            Token           = new OAuthParameter("oauth_token", tokens.AccessToken);
            TokenSecret     = new OAuthParameter("oauth_token_secret", tokens.AccessTokenSecret);
        }
예제 #5
0
 public TwitterDataProvider(TwitterOAuthTokens tokens)
 {
     _tokens = tokens;
 }