RT用新浪微博登录的可以成功.可是用腾讯的却怎么也弄不好.
新浪微博有个验证的API,可我在腾讯微博怎么也找不到
Uri uri = new Uri("http://api.t.sina.com.cn/account/verify_credentials.xml");请高手帮个忙.....就这差一步了.另如需要,我可以贴出新浪微博登录的代码...

解决方案 »

  1.   


     public partial class _Default : System.Web.UI.Page
        {
            OAuthBase oAuth = new OAuthBase();
            //string apiKey = "158725896";//申请的App Key
            //string apiKeySecret = "90891d81a0119e294b9089e90d07faa5";//申请的App Secret
            string apiKey = "1006676182";//申请的App Key
            string apiKeySecret = "4f35b6b1d977f23379d71ea7e67703ed";//申请的App Secret
            string requestTokenUri = "http://api.t.sina.com.cn/oauth/request_token";
            string AUTHORIZE = "http://api.t.sina.com.cn/oauth/authorize";
            string ACCESS_TOKEN = "http://api.t.sina.com.cn/oauth/access_token";
            //string apiKey ="801061653";
            //string apiKeySecret = "da8f35f9bb6a07f94dad79cab8d3e47e";
            //string requestTokenUri = "https://open.t.qq.com/cgi-bin/authorize";
            //string requestTokenUri = "https://open.t.qq.com/cgi-bin/access_token";
            //string ACCESS_TOKEN = "https://open.t.qq.com/cgi-bin/request_token";
                
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!string.IsNullOrEmpty(Request["oauth_verifier"]))
                {
                    string abc = Request["oauth_verifier"].ToString();
                    string bcd = Request["oauth_token"].ToString();
                    getAccessToken(Request["oauth_token"].ToString(), Request["oauth_verifier"].ToString());
                }
                else
                {
                    ImageButton1.Visible = true;
                }
            }        public void getAccessToken(string requestToken, string oauth_verifier)
            {
                Uri uri = new Uri(ACCESS_TOKEN);
                string nonce = oAuth.GenerateNonce();
                string timeStamp = oAuth.GenerateTimeStamp();
                string normalizeUrl, normalizedRequestParameters;
                // 签名
                string sig = oAuth.GenerateSignature(
                uri,
                apiKey,
                apiKeySecret,
                requestToken,
                Session["oauth_token_secret"].ToString(),
                "Get",
                timeStamp,
                nonce,
                oauth_verifier,
                out normalizeUrl,
                out normalizedRequestParameters);
                sig = oAuth.UrlEncode(sig);
                //构造请求Access Token的url
                StringBuilder sb = new StringBuilder(uri.ToString());
                sb.AppendFormat("?oauth_consumer_key={0}&", apiKey);
                sb.AppendFormat("oauth_nonce={0}&", nonce);
                sb.AppendFormat("oauth_timestamp={0}&", timeStamp);
                sb.AppendFormat("oauth_signature_method={0}&", "HMAC-SHA1");
                sb.AppendFormat("oauth_version={0}&", "1.0");
                sb.AppendFormat("oauth_signature={0}&", sig);
                sb.AppendFormat("oauth_token={0}&", requestToken);
                sb.AppendFormat("oauth_verifier={0}", oauth_verifier);
                //请求Access Token
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sb.ToString());
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                StreamReader stream = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
                string responseBody = stream.ReadToEnd();
                stream.Close();
                response.Close();
                int intOTS = responseBody.IndexOf("oauth_token=");
                int intOTSS = responseBody.IndexOf("&oauth_token_secret=");
                int intUser = responseBody.IndexOf("&user_id=");
                Session["oauth_token"] = responseBody.Substring(intOTS + 12, intOTSS - (intOTS + 12));
                Session["oauth_token_secret"] = responseBody.Substring((intOTSS + 20), intUser - (intOTSS + 20));
                Session["User_Id"] = responseBody.Substring((intUser + 9), responseBody.Length - (intUser + 9));
                verify_credentials();
            }        public void getRequestToken()
            {
                Uri uri = new Uri(requestTokenUri);
                string nonce = oAuth.GenerateNonce();//获取随机生成的字符串,防止攻击
                string timeStamp = oAuth.GenerateTimeStamp();//发起请求的时间戳
                string normalizeUrl, normalizedRequestParameters;
                // 签名
                string sig = oAuth.GenerateSignature(uri, apiKey, apiKeySecret, string.Empty, string.Empty, "GET", timeStamp, nonce, string.Empty, out normalizeUrl, out normalizedRequestParameters);
                sig = HttpUtility.UrlEncode(sig);
                //构造请求Request Token的url
                StringBuilder sb = new StringBuilder(uri.ToString());
                sb.AppendFormat("?oauth_consumer_key={0}&", apiKey);
                sb.AppendFormat("oauth_nonce={0}&", nonce);
                sb.AppendFormat("oauth_signature={0}&", sig);
                sb.AppendFormat("oauth_signature_method={0}&", "HMAC-SHA1");
                sb.AppendFormat("oauth_timestamp={0}&", timeStamp);
                sb.AppendFormat("oauth_version={0}", "1.0");
                //请求Request Token
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sb.ToString());
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                StreamReader stream = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
                string responseBody = stream.ReadToEnd();
                stream.Close();
                response.Close();
                int intOTS = responseBody.IndexOf("oauth_token=");
                int intOTSS = responseBody.IndexOf("&oauth_token_secret=");
                Session["oauth_token"] = responseBody.Substring(intOTS + 12, intOTSS - (intOTS + 12));
                Session["oauth_token_secret"] = responseBody.Substring((intOTSS + 20), responseBody.Length - (intOTSS + 20));
                Response.Redirect(AUTHORIZE + "?oauth_token=" + Session["oauth_token"] + "&oauth_callback=" + Request.Url);
            }        public void verify_credentials()
            {
                Uri uri = new Uri("http://api.t.sina.com.cn/account/verify_credentials.xml");
                string nonce = oAuth.GenerateNonce();
                string timeStamp = oAuth.GenerateTimeStamp();
                string normalizeUrl, normalizedRequestParameters;
                // 签名
                string sig = oAuth.GenerateSignature(
                uri,
                apiKey,
                apiKeySecret,
                Session["oauth_token"].ToString(),
                Session["oauth_token_secret"].ToString(),
                "Get",
                timeStamp,
                nonce,
                string.Empty,
                out normalizeUrl,
                out normalizedRequestParameters);
                sig = HttpUtility.UrlEncode(sig);
                StringBuilder sb = new StringBuilder(uri.ToString());
                sb.AppendFormat("?oauth_consumer_key={0}&", apiKey);
                sb.AppendFormat("oauth_nonce={0}&", nonce);
                sb.AppendFormat("oauth_timestamp={0}&", timeStamp);
                sb.AppendFormat("oauth_signature_method={0}&", "HMAC-SHA1");
                sb.AppendFormat("oauth_version={0}&", "1.0");
                sb.AppendFormat("oauth_signature={0}&", sig);
                sb.AppendFormat("oauth_token={0}&", Session["oauth_token"].ToString());
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sb.ToString());
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                StreamReader stream = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
                string responseBody = stream.ReadToEnd();
                stream.Close();
                response.Close();
                Session["responseBody"] = responseBody;//用户个人信息在这个里面了!!
                Response.Redirect("webform1.aspx");//成功后跳转到的页面
            }
            protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
            {
                getRequestToken();
            }    }
      

  2.   

    http://open.t.qq.com/resource.php?i=1,1#6_10所有的API及说明都在这了,自己看。还有好像安装一个插件后也可以的。http://nt.discuz.net/showtopic-139606.html
      

  3.   


    可是我找不到验证的URL
    像上面代码中新浪的 http://api.t.sina.com.cn/account/verify_credentials.xml
      

  4.   

    http://open.t.qq.com/api/user/info 这样的不行吗