FlickrAPI请求签名无效(控制台模拟)为了我自己。然后,我将使用我将了解的有关FlickAPI的新功能扩展此应用程序。所以这只是我想玩的东西。但是现在我在获取请求令牌时遇到了一些问题。我在这里遵循了Flickr身份验证文档:Flickr身份验证我还找到了这个Mathlabscript:FlickrAPI和基于OAuth的用户身份验证因此,基于这些来源,我现在有以下控制台应用程序:私有静态字符串ConsumerKey="1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a";staticvoidMain(string[]args){Randomrand=newRandom();stringnonce=rand.Next(9999999).ToString();字符串时间戳=((int)(DateTime.UtcNow-newDateTime(1970,1,1)).TotalSeconds).ToString();Console.WriteLine("随机数:"+随机数);Console.WriteLine("时间戳:"+时间戳);安慰。WriteLine("消费者密钥:"+ConsumerKey);Console.WriteLine("AppSecret:"+Secret);//请求urlStringBuilderb=newStringBuilder();b.Append("http://www.flickr.com/services/oauth/request_token");b.追加("?");b.Append("oauth_nonce=");b.追加(随机数);b.Append("&oauth_timestamp=");b.追加(时间戳);b.Append("&oauth_consumer_key=");b.追加(消费者密钥);b.Append("&oauth_callback=oob");b.Append("&oauth_signature_method=HMAC-SHA1");字符串requesturl=b.ToString();Console.WriteLine("RequestUrl:"+requesturl);//基本url字符串basestring;StringBuilderbs=newStringBuilder();bs.Append("GET&");bs.Append(UrlHelper.Encode("http://www.flickr.com/services/oauth/request_token")+"&");basestring=bs.ToString();StringBuilderp=newStringBuilder();p.Append("oauth_callback=oob");p.Append("&oauth_consumer_key=");p.Append(ConsumerKey);p.Append("oauth_nonce=");p.Append(nonce);p.Append("&oauth_signature_method=HMAC-SHA1");p.Append("&oauth_timestamp=");p.Append(时间戳);字符串参数=UrlHelper.Encode(p.ToString());basestring+=参数;Console.WriteLine("基础字符串:"+基础字符串);System.Text.ASCIIEncoding编码=newSystem.Text.ASCIIEncoding();字符串键=秘密+“&”;Console.WriteLine("密钥:"+密钥);byte[]keyByte=encoding.GetBytes(键);//--创建消息加密byte[]messageBytes=encoding.GetBytes(basestring);//--使用hmac-sha1和提供的密钥HMACSHA1加密消息hmacsha1=newHMACSHA1(keyByte);byte[]hashmessage=hmacsha1.ComputeHash(messageBytes);//--签名字符串signature=ByteToString(hashmessage);Console.WriteLine("签名:"+signature);Console.WriteLine("最终请求:"+requesturl+"&oauth_signature="+signature);控制台.ReadKey(true);}publicstaticstringByteToString(byte[]buff){stringsbinary="";对于(inti=0;i
