private NameValueCollection GetAccessToken(string oauth_token, string oauth_verifier) { var helper = new TwitterUrlHelper(TWITTER_ACCESSTOKEN_URL); var parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("oauth_consumer_key", _twitterSettings.ConsumerKey)); parameters.Add(new KeyValuePair <string, string>("oauth_nonce", CreateNonce())); parameters.Add(new KeyValuePair <string, string>("oauth_signature_method", "HMAC-SHA1")); parameters.Add(new KeyValuePair <string, string>("oauth_timestamp", CreateTimeStamp())); parameters.Add(new KeyValuePair <string, string>("oauth_token", oauth_token)); parameters.Add(new KeyValuePair <string, string>("oauth_verifier", oauth_verifier)); parameters.Add(new KeyValuePair <string, string>("oauth_version", OAUTH_VERSION)); var signature = helper.CreateSignature(_twitterSettings.ConsumerSecret, parameters, null); parameters.Insert(2, new KeyValuePair <string, string>("oauth_signature", signature)); using (var client = new WebClient()) { var url = helper.CreateCallingUrls(parameters); var response = client.DownloadString(url); var dict = HttpUtility.ParseQueryString(response); return(dict); } }
private string GetAccount(string authToken, string authTokenSecret) { var helper = new TwitterUrlHelper(TWITTER_ACCOUNT_URL); var parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("include_email", "true")); parameters.Add(new KeyValuePair <string, string>("oauth_consumer_key", _twitterSettings.ConsumerKey)); parameters.Add(new KeyValuePair <string, string>("oauth_nonce", CreateNonce())); parameters.Add(new KeyValuePair <string, string>("oauth_signature_method", "HMAC-SHA1")); parameters.Add(new KeyValuePair <string, string>("oauth_timestamp", CreateTimeStamp())); parameters.Add(new KeyValuePair <string, string>("oauth_token", authToken)); parameters.Add(new KeyValuePair <string, string>("oauth_version", OAUTH_VERSION)); var signature = helper.CreateSignature(_twitterSettings.ConsumerSecret, parameters, authTokenSecret); parameters.Insert(3, new KeyValuePair <string, string>("oauth_signature", signature)); using (var client = new WebClient()) { var url = helper.CreateCallingUrls(parameters); var response = client.DownloadString(url); return(response); } }