日期:2014-05-18  浏览次数:20777 次

求助,腾讯微博API oauth_signature
C# code
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();




从早上9点一直被卡在oauth_signature 这个签名这边,到现在还是毫无进展,总是错的,401错误。

------解决方案--------------------
HTTP 401.1 - 未授权:登录失败 
HTTP 401.2 - 未授权:服务器配置问题导致登录失败 
HTTP 401.3 - ACL 禁止访问资源 
HTTP 401.4 - 未授权:授权被筛选器拒绝 
HTTP 401.5 - 未授权:ISAPI 或 CGI 授权失败 

你是属于哪一种呢?
------解决方案--------------------
参考:http://blog.csdn.net/fangxinggood/article/details/6629358
------解决方案--------------------
看楼上的帖子就来了

OAuth 登陆方式已经成为主流的登陆方式。

原理都是一样。
------解决方案--------------------
OAuth 已经 取代了 XAuth 
现在很多平台都取消 或 限制了 XAuth登陆的方式。