/// <summary> /// 获取微博账号的OpenID /// </summary> /// <param name="qqOauthInfo"></param> /// <returns></returns> public string GetOpenID(WeiboOauthInfo oauthInfo) { string res = LoadHtmlUserGetType("https://api.weibo.com/2/account/get_uid.json?access_token=" + oauthInfo.Access_token, Encoding.UTF8, "GET"); WeiboUserID userInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <WeiboUserID>(res); return(userInfo.Uid); }
/// <summary> /// 获取微博昵称 /// </summary> /// <param name="qqOauthInfo"></param> /// <param name="openID"></param> /// <returns></returns> public string GetUserInfo(WeiboOauthInfo WeiboOauthInfo, string userID) { string urlGetInfo = string.Format(@"https://api.weibo.com/2/users/show.json?access_token={0}&uid={1}", WeiboOauthInfo.Access_token, userID); string jsonUserInfo = LoadHtmlUserGetType(urlGetInfo, Encoding.UTF8, "GET"); WeiboFullUserInfo fullUserInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <WeiboFullUserInfo>(jsonUserInfo); return(fullUserInfo.Screen_name); }
/// <summary> /// 获取oauth信息 /// </summary> /// <param name="code"></param> /// <returns></returns> public WeiboOauthInfo GetOauthInfo(string code) { string callback = System.Web.HttpUtility.UrlEncode(WeiboCallBack, Encoding.UTF8); string url = string.Format("https://api.weibo.com/oauth2/access_token?grant_type={0}&client_id={1}&client_secret={2}&code={3}&redirect_uri={4}", "authorization_code", AppId, AppKey, code, callback); string res = LoadHtmlUserGetType(url, Encoding.UTF8, "POST"); WeiboOauthInfo OauthInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <WeiboOauthInfo>(res); return(OauthInfo); }