我正在使用 OauthBase.cs 类生成签名,但不断收到错误消息,指出签名无效。谁能告诉我哪里出错了?
我暂时将其显示在消息框中,然后将其复制并粘贴到浏览器中以进行检查。
这是我的代码..
string consumerKey = "consumer_key";
string consumerSecret = "consumer_secret";
string normalizedUrl = null;
string normalizedRequestParameters = null;
Uri url = new Uri("http://www.flickr.com/services/oauth/request_token");
oAuthBase oAuth = new oAuthBase();
string nonce = oAuth.GenerateNonce();
string timeStamp = oAuth.GenerateTimeStamp();
string callback = oAuth.UrlEncode("http://www.example.com");
string sig = oAuth.GenerateSignature(url, consumerKey, consumerSecret, string.Empty , string.Empty , "GET", timeStamp, nonce, callback , oAuthBase.SignatureTypes.HMACSHA1,out normalizedUrl ,out normalizedRequestParameters );
sig = HttpUtility.UrlEncode(sig);
StringBuilder sb = new StringBuilder(url.ToString());
sb.AppendFormat("?oauth_nonce={0}&", nonce);
sb.AppendFormat("oauth_timestamp={0}&", timeStamp);
sb.AppendFormat("oauth_consumer_key={0}&", consumerKey);
sb.AppendFormat("oauth_signature_method={0}&", "HMAC-SHA1");
sb.AppendFormat("oauth_version={0}&", "1.0");
sb.AppendFormat("oauth_signature={0}", sig);
sb.AppendFormat("oauth_callback={0}", callback);
MessageBox.Show(sb.ToString());