我执行了本文档implementing sign in twitter中的步骤,所有操作都是一步一步完成的,直到我想要使用GET {{3}获取用户数据(屏幕名称,ID和名称)的最后一步但我不知道这段代码有什么问题
string oauthRequestTokenUrl =
"https://api.twitter.com/1.1/account/verify_credentials.json";
//var oauthCallback = "http://localhost:14993/WebForm1.aspx";
string oauthNonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()));
string oauthSignatureMethod = "HMAC-SHA1";
string oauthTimestamp =
Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds,
CultureInfo.CurrentCulture).ToString(CultureInfo.CurrentCulture);
string oauthSignature =
"oauth_consumer_key=" + UrlEncode(ApiKey) + "&" +
"oauth_nonce=" + UrlEncode(oauthNonce) + "&" +
"oauth_signature_method=" + UrlEncode(oauthSignatureMethod) + "&" +
"oauth_timestamp=" + UrlEncode(oauthTimestamp) + "&" +
"oauth_token=" + UrlEncode(dic["oauth_token"]) + "&" +
"oauth_token_secret=" + UrlEncode(dic["oauth_token_secret"]) + "&" +
"oauth_version=" + UrlEncode("1.0");
oauthSignature = "GET" + "&" + UrlEncode(oauthRequestTokenUrl) + "&" + UrlEncode(oauthSignature);
oauthSignature =
Convert.ToBase64String(
(new HMACSHA1(Encoding.ASCII.GetBytes(UrlEncode(ApiSecret) + "&"))).ComputeHash(
Encoding.ASCII.GetBytes(oauthSignature)));
string header =
"OAuth realm=\"Twitter API\"," +
"oauth_consumer_key=\"" + UrlEncode(ApiKey) + "\"," +
"oauth_nonce=\"" + UrlEncode(oauthNonce) + "\"," +
"oauth_signature=\"" + UrlEncode(oauthSignature) + "\"," +
"oauth_signature_method=\"" + UrlEncode(oauthSignatureMethod) + "\"," +
"oauth_timestamp=\"" + UrlEncode(oauthTimestamp) + "\"," +
"oauth_token_secret=\"" + UrlEncode(dic["oauth_token_secret"]) + "\"," +
"oauth_token=\"" + UrlEncode(dic["oauth_token"]) + "\"," +
"oauth_version=\"" + UrlEncode("1.0") + "\"";
var authRequest = (HttpWebRequest)
WebRequest.Create(oauthRequestTokenUrl);
authRequest.Method = "GET";
//authRequest.ContentType = "application/x-www-form-urlencoded";
authRequest.ServicePoint.Expect100Continue = false;
authRequest.Headers.Add("Authorization", header);
var authResponse = (HttpWebResponse)authRequest.GetResponse();
Stream stream = authResponse.GetResponseStream();
var objectText = new StreamReader(stream).ReadToEnd();