日期:2014-05-18 浏览次数:20969 次
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
string G_oauth_nonce = Guid.NewGuid().ToString().Replace("-", "");
string G_oauth_timestamp = Convert.ToInt64(ts.TotalSeconds).ToString();
string requestMethod = "GET&";
string requestUrl = "https%3A%2F%2Fopen.t.qq.com%2Fcgi-bin%2Frequest_token";
string canshu = HttpUtility.UrlEncode("oauth_callback=null&oauth_consumer_key="+AppKey+"&oauth_nonce=" + G_oauth_timestamp + "&oauth_signature_method=HMAC-SHA1&oauth_timestamp=" + G_oauth_timestamp + "&oauth_version=1.0");
HMACSHA1 hmacsha1 = new HMACSHA1();
hmacsha1.Key = Encoding.ASCII.GetBytes(string.Format("{0}&{1}", HttpUtility.UrlEncode(AppSecret), HttpUtility.UrlEncode(requestMethod + requestUrl + canshu)));
string msg = "https://open.t.qq.com/cgi-bin/request_token?oauth_callback=null&oauth_consumer_key="+AppKey+"&oauth_nonce=" + G_oauth_nonce + "&oauth_signature=" +Convert.ToBase64String(hmacsha1.Key) + "&oauth_signature_method=HMAC-SHA1&oauth_timestamp=" + G_oauth_timestamp + "&oauth_version=1.0";
retrun oStream.ReadToEnd().ToString();