//3.获取用户信息 #region 请求参数 /* * 请求参数 * 字段 必选 类型及范围 说明 默认值 * access_token true string oauth2_token获取的access_token * dataType true string 返回数据类型['json'|'jsonp'|'xml'] json * ************************************8888 *返回字段说明 * 字段 类型及范围 说明 * error string 错误 * error_description string 错误描述 * id string 用户ID * email string 用户email * name string 用户名 * gender string 性别 * avatar string 头像 * location string 地点 * url string 主页 */ #endregion #region 获取用户基本信息 /// <summary> /// 获取用户基本信息 /// </summary> /// <returns></returns> public Dictionary <string, object> GetUserBaseInfo() { try { Dictionary <string, object> result = Conf.GetDictionary(UserBaseInfoUrl, Access_Token, "json"); if (result != null && result.Count > 0) { UserBaseInfo = new OSCUserBaseInfo() { id = result["id"].ToString(), email = result["email"].ToString(), name = result["name"].ToString(), gender = result["gender"].ToString(), avatar = result["avatar"].ToString(), location = result["location"].ToString(), url = result["url"].ToString() }; } return(result); } catch (Exception ex) { return(null); } }
//4.获取用户信息 #region 获取用户基本信息 /// <summary> /// 获取用户基本信息 /// </summary> /// <returns>用户基本信息对象</returns> public QQUserInfo GetUserInfo() { try { QQUserInfo model = null; Dictionary <string, object> result = Conf.GetDictionary(UserBaseInfoUrl, Access_Token, Conf.QQ_Client_ID, Open_ID); if (result != null && result.Count > 0) { string ret = result["ret"].ToString(); //返回码 string msg = result["msg"].ToString(); //如果ret<0,会有相应的错误信息提示,返回数据全部用UTF-8编码 if (ret == "0") { model = new QQUserInfo() { NickName = result["nickname"].ToString(), FigureURL = result["figureurl"].ToString(), FigureURL_1 = result["figureurl_1"].ToString(), FigureURL_2 = result["figureurl_2"].ToString(), FigureURL_QQ_1 = result["figureurl_qq_1"].ToString(), FigureURL_QQ_2 = result["figureurl_qq_2"].ToString(), Gender = result["gender"].ToString(), Is_Yellow_VIP = result["is_yellow_vip"].ToString(), Yellow_VIP_Level = result["yellow_vip_level"].ToString(), Is_Yellow_Year_VIP = result["is_yellow_year_vip"].ToString() }; this.UserInfo = model; } } return(model); } catch (Exception ex) { throw ex; } }
//3.获取用户信息 #region 请求参数 /* * 请求参数 * 基于https调用Open API时需要传递的系统级输入参数: * * 参数名 参数类型 是否必需 描述 * access_token string 是 授权码,应用访问百度的任何Restful Open API都必须出具授权码以表明其是一个合法第三方。其值必须是通过OAuth2.0协议换取access token时所拿到的access_token参数值。 * ************************************ *返回字段说明 * { * "login": "******", * "id": 1, * "avatar_url": "https://github.com/images/error/octocat_happy.gif", * "gravatar_id": "", * "url": "https://api.github.com/users/octocat", * "html_url": "https://github.com/octocat", * "followers_url": "https://api.github.com/users/octocat/followers", * "following_url": "https://api.github.com/users/octocat/following{/other_user}", * "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", * "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", * "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", * "organizations_url": "https://api.github.com/users/octocat/orgs", * "repos_url": "https://api.github.com/users/octocat/repos", * "events_url": "https://api.github.com/users/octocat/events{/privacy}", * "received_events_url": "https://api.github.com/users/octocat/received_events", * "type": "User", * "site_admin": false, * "name": "monalisa octocat", * "company": "GitHub", * "blog": "https://github.com/blog", * "location": "San Francisco", * "email": "*****@*****.**", * "hireable": false, * "bio": "There once was...", * "public_repos": 2, * "public_gists": 1, * "followers": 20, * "following": 0, * "created_at": "2008-01-14T04:33:35Z", * "updated_at": "2008-01-14T04:33:35Z", * "total_private_repos": 100, * "owned_private_repos": 100, * "private_gists": 81, * "disk_usage": 10000, * "collaborators": 8, * "plan": { * "name": "Medium", * "space": 400, * "private_repos": 20, * "collaborators": 0 * } * } */ #endregion #region 获取用户基本信息 /// <summary> /// 获取用户基本信息 /// </summary> /// <returns></returns> public Dictionary <string, object> GetUserBaseInfo() { try { Dictionary <string, object> result = Conf.GetDictionary(UserBaseInfoUrl, Access_Token); //string json = result["plan"].ToString(); //Dictionary<string, object> plan = JsonHelper.Deserialize<Dictionary<string, object>>(json); if (result != null && result.Count > 0) { this.UserBaseInfo = new GitHubUserInfo() { login = result["login"].ToString(), id = result["id"].ToString(), avatar_url = result["avatar_url"].ToString(), gravatar_id = result["gravatar_id"].ToString(), url = result["url"].ToString(), html_url = result["html_url"].ToString(), followers_url = result["followers_url"].ToString(), following_url = result["following_url"].ToString(), gists_url = result["gists_url"].ToString(), starred_url = result["starred_url"].ToString(), subscriptions_url = result["subscriptions_url"].ToString(), organizations_url = result["organizations_url"].ToString(), repos_url = result["repos_url"].ToString(), events_url = result["events_url"].ToString(), received_events_url = result["received_events_url"].ToString(), type = result["type"].ToString(), site_admin = result["site_admin"].ToString(), name = result["name"].ToString(), company = result["company"].ToString(), blog = result["blog"].ToString(), location = result["location"].ToString(), email = result["email"].ToString(), hireable = result["hireable"].ToString(), bio = result["bio"] != null ? result["bio"].ToString(): null, public_repos = result["public_repos"].ToString(), public_gists = result["public_gists"].ToString(), followers = result["followers"].ToString(), following = result["following"].ToString(), created_at = result["created_at"].ToString(), updated_at = result["updated_at"].ToString(), //total_private_repos = result["total_private_repos"].ToString(), //owned_private_repos = result["owned_private_repos"].ToString(), //private_gists = result["private_gists"].ToString(), //disk_usage = result["disk_usage"].ToString(), //collaborators = result["collaborators"].ToString(), //plan_name = plan["name"].ToString(), //plan_space = plan["space"].ToString(), //plan_private_repos = plan["private_repos"].ToString(), //plan_collaborators = plan["collaborators"].ToString() }; } return(result); } catch (Exception ex) { return(null); } }
//3.获取用户信息 #region 参数 /* * 返回字段说明 * 字段 字段类型 字段说明 * id int64 用户UID * idstr string 字符串型的用户UID * screen_name string 用户昵称 * name string 友好显示名称 * province int 用户所在省级ID * city int 用户所在城市ID * location string 用户所在地 * description string 用户个人描述 * url string 用户博客地址 * profile_image_url string 用户头像地址(中图),50×50像素 * profile_url string 用户的微博统一URL地址 * domain string 用户的个性化域名 * weihao string 用户的微号 * gender string 性别,m:男、f:女、n:未知 * followers_count int 粉丝数 * friends_count int 关注数 * statuses_count int 微博数 * favourites_count int 收藏数 * created_at string 用户创建(注册)时间 * following boolean 暂未支持 * allow_all_act_msg boolean 是否允许所有人给我发私信,true:是,false:否 * geo_enabled boolean 是否允许标识用户的地理位置,true:是,false:否 * verified boolean 是否是微博认证用户,即加V用户,true:是,false:否 * verified_type int 暂未支持 * remark string 用户备注信息,只有在查询用户关系时才返回此字段 * status object 用户的最近一条微博信息字段 详细 * allow_all_comment boolean 是否允许所有人对我的微博进行评论,true:是,false:否 * avatar_large string 用户头像地址(大图),180×180像素 * avatar_hd string 用户头像地址(高清),高清头像原图 * verified_reason string 认证原因 * follow_me boolean 该用户是否关注当前登录用户,true:是,false:否 * online_status int 用户的在线状态,0:不在线、1:在线 * bi_followers_count int 用户的互粉数 * lang string 用户当前的语言版本,zh-cn:简体中文,zh-tw:繁体中文,en:英语 */ #endregion #region 获取用户基本信息 /// <summary> /// 获取用户基本信息 /// </summary> /// <returns></returns> public Dictionary <string, object> GetUserBaseInfo() { try { Dictionary <string, object> result = Conf.GetDictionary(UserBaseInfoUrl, Access_Token, this.UID); if (result != null && result.Count > 0) { //string error = result["error"].ToString(); //string error_description = result["error_description"].ToString(); UserBaseInfo = new SinaUserInfo() { id = long.Parse(result["id"].ToString()), idstr = result["idstr"].ToString(), screen_name = result["screen_name"].ToString(), name = result["name"].ToString(), province = int.Parse(result["province"].ToString()), city = int.Parse(result["city"].ToString()), location = result["location"].ToString(), description = result["description"].ToString(), url = result["url"].ToString(), profile_image_url = result["profile_image_url"].ToString(), profile_url = result["profile_url"].ToString(), domain = result["domain"].ToString(), weihao = result["weihao"].ToString(), gender = result["gender"].ToString(), followers_count = int.Parse(result["followers_count"].ToString()), friends_count = int.Parse(result["friends_count"].ToString()), statuses_count = int.Parse(result["statuses_count"].ToString()), favourites_count = int.Parse(result["favourites_count"].ToString()), created_at = result["created_at"].ToString(), following = bool.Parse(result["following"].ToString()), allow_all_act_msg = bool.Parse(result["allow_all_act_msg"].ToString()), geo_enabled = bool.Parse(result["geo_enabled"].ToString()), verified = bool.Parse(result["verified"].ToString()), verified_type = int.Parse(result["verified_type"].ToString()), remark = result["remark"].ToString(), status = result["status"].ToString(), allow_all_comment = bool.Parse(result["allow_all_comment"].ToString()), avatar_large = result["avatar_large"].ToString(), avatar_hd = result["avatar_hd"].ToString(), verified_reason = result["verified_reason"].ToString(), follow_me = bool.Parse(result["follow_me"].ToString()), online_status = int.Parse(result["online_status"].ToString()), bi_followers_count = int.Parse(result["bi_followers_count"].ToString()), lang = result["lang"].ToString() }; } return(result); } catch (Exception ex) { return(null); } }
//3.获取用户信息 #region 获取用户基本信息 /// <summary> /// 获取用户基本信息 /// </summary> /// <returns>用户基本信息类</returns> public SinaUserInfo GetUserInfo() { try { SinaUserInfo model = null; Dictionary <string, object> result = Conf.GetDictionary(UserBaseInfoUrl, Access_Token, this.UID); if (result != null && result.Count > 0) { model = new SinaUserInfo() { id = long.Parse(result["id"].ToString()), //用户UID idstr = result["idstr"].ToString(), //字符串型的用户UID screen_name = result["screen_name"].ToString(), //用户昵称 name = result["name"].ToString(), //友好显示名称 province = int.Parse(result["province"].ToString()), //用户所在省级ID city = int.Parse(result["city"].ToString()), //用户所在城市ID location = result["location"].ToString(), //用户所在地 description = result["description"].ToString(), //用户个人描述 url = result["url"].ToString(), //用户博客地址 profile_image_url = result["profile_image_url"].ToString(), //用户头像地址(中图),50×50像素 profile_url = result["profile_url"].ToString(), //用户的微博统一URL地址 domain = result["domain"].ToString(), //用户的个性化域名 weihao = result["weihao"].ToString(), //用户的微号 gender = result["gender"].ToString(), //性别,m:男、f:女、n:未知 followers_count = int.Parse(result["followers_count"].ToString()), //粉丝数 friends_count = int.Parse(result["friends_count"].ToString()), //关注数 statuses_count = int.Parse(result["statuses_count"].ToString()), //微博数 favourites_count = int.Parse(result["favourites_count"].ToString()), //收藏数 created_at = result["created_at"].ToString(), //用户创建(注册)时间 following = bool.Parse(result["following"].ToString()), //暂未支持 allow_all_act_msg = bool.Parse(result["allow_all_act_msg"].ToString()), //是否允许所有人给我发私信,true:是,false:否 geo_enabled = bool.Parse(result["geo_enabled"].ToString()), //是否允许标识用户的地理位置,true:是,false:否 verified = bool.Parse(result["verified"].ToString()), //是否是微博认证用户,即加V用户,true:是,false:否 verified_type = int.Parse(result["verified_type"].ToString()), //暂未支持 remark = result["remark"].ToString(), //用户备注信息,只有在查询用户关系时才返回此字段 status = result["status"].ToString(), //用户的最近一条微博信息字段 详细 allow_all_comment = bool.Parse(result["allow_all_comment"].ToString()), //是否允许所有人对我的微博进行评论,true:是,false:否 avatar_large = result["avatar_large"].ToString(), //用户头像地址(大图),180×180像素 avatar_hd = result["avatar_hd"].ToString(), //用户头像地址(高清),高清头像原图 verified_reason = result["verified_reason"].ToString(), //认证原因 follow_me = bool.Parse(result["follow_me"].ToString()), //该用户是否关注当前登录用户,true:是,false:否 online_status = int.Parse(result["online_status"].ToString()), //用户的在线状态,0:不在线、1:在线 bi_followers_count = int.Parse(result["bi_followers_count"].ToString()), //用户的互粉数 lang = result["lang"].ToString() //用户当前的语言版本,zh-cn:简体中文,zh-tw:繁体中文,en:英语 }; UserInfo = model; } return(model); } catch (Exception ex) { throw ex; } }
//3.获取用户信息 #region 请求参数 /* * 请求参数 * 基于https调用Open API时需要传递的系统级输入参数: * * 参数名 参数类型 是否必需 描述 * access_token string 是 授权码,应用访问百度的任何Restful Open API都必须出具授权码以表明其是一个合法第三方。其值必须是通过OAuth2.0协议换取access token时所拿到的access_token参数值。 * ************************************ *返回字段说明 * "id": "1462702590710348", * "first_name": "Seay", * "gender": "male", * "last_name": "Xu", * "link": "https://www.facebook.com/app_scoped_user_id/1462702590710348/", * "locale": "zh_CN", * "name": "Seay Xu", * "timezone": 8, * "updated_time": "2015-06-30T05:50:43+0000", * "verified": true */ #endregion #region 获取用户基本信息 /// <summary> /// 获取用户基本信息 /// </summary> /// <returns></returns> public Dictionary <string, object> GetUserBaseInfo() { try { Dictionary <string, object> result = Conf.GetDictionary(UserBaseInfoUrl, Access_Token); if (result != null && result.Count > 0) { this.UserBaseInfo = new GitHubUserInfo() { login = result["login"].ToString(), id = result["id"].ToString(), avatar_url = result["avatar_url"].ToString(), gravatar_id = result["gravatar_id"].ToString(), url = result["url"].ToString(), html_url = result["html_url"].ToString(), followers_url = result["followers_url"].ToString(), following_url = result["following_url"].ToString(), gists_url = result["gists_url"].ToString(), starred_url = result["starred_url"].ToString(), subscriptions_url = result["subscriptions_url"].ToString(), organizations_url = result["organizations_url"].ToString(), repos_url = result["repos_url"].ToString(), events_url = result["events_url"].ToString(), received_events_url = result["received_events_url"].ToString(), type = result["type"].ToString(), site_admin = result["site_admin"].ToString(), name = result["name"].ToString(), company = result["company"].ToString(), blog = result["blog"].ToString(), location = result["location"].ToString(), email = result["email"].ToString(), hireable = result["hireable"].ToString(), bio = result["bio"] != null ? result["bio"].ToString() : null, public_repos = result["public_repos"].ToString(), public_gists = result["public_gists"].ToString(), followers = result["followers"].ToString(), following = result["following"].ToString(), created_at = result["created_at"].ToString(), updated_at = result["updated_at"].ToString() }; } return(result); } catch (Exception ex) { return(null); } }
//2.获取Token #region 请求参数 /* * 请求参数 * Name Type Description * client_id string Required. The client ID you received from GitHub when you registered. * client_secret string Required. The client secret you received from GitHub when you registered. * code string Required. The code you received as a response to Step 1. * redirect_uri string The URL in your app where users will be sent after authorization. See details below about redirect urls. * **************************************************************************** * 返回字段说明 * access_token=e72e16c7e42f292c6912e7710c838347ae178b4a&scope=user%2Cgist&token_type=bearer * * You can also receive the content in different formats depending on the Accept header: * Accept: application/json * {"access_token":"e72e16c7e42f292c6912e7710c838347ae178b4a", "scope":"repo,gist", "token_type":"bearer"} * * Accept: application/xml * <OAuth> * <token_type>bearer</token_type> * <scope>repo,gist</scope> * <access_token>e72e16c7e42f292c6912e7710c838347ae178b4a</access_token> * </OAuth> */ #endregion #region 获取Token /// <summary> /// 获取Token /// </summary> /// <param name="code"></param> /// <param name="state"></param> /// <returns></returns> public Dictionary <string, object> Token(string code, string state) { try { Dictionary <string, object> result = Conf.GetDictionary(string.Format(TokenUrl, Conf.FaceBook_Client_ID, Conf.FaceBook_Client_Secret, Conf.FaceBook_Callback_URL, code)); if (result != null) { this.Access_Token = result["access_token"].ToString(); this.Expires_In = result["expires_in"].ToString(); this.Token_Type = result["token_type"].ToString(); } return(result); } catch (Exception ex) { return(null); } }
//4.获取用户详细信息 #region 请求参数 /* * 返回字段说明 * 字段 类型及范围 说明 * uid long 被查询用户id * name string 用户名称 * gender int 性别:1-男,2-女 * province string 省份 * city string 城市 * platforms array 开发平台 * expertise array 专长领域 * joinTime datetime 加入时间 * lastLoginTime datetime 最近登录时间 * portrait string 头像 * fansCount string 粉丝数 * favoriteCount string 收藏数 * followersCount string 关注数 * notice.replyCount int 未读评论数 * notice.msgCount int 未读留言数 * notice.fansCount int 新增粉丝数 * notice.referCount int 未读@我数 */ #endregion #region 获取用户详细信息 /// <summary> /// 获取用户详细信息 /// </summary> /// <returns></returns> public Dictionary <string, object> GetUserDetailInfo() { try { Dictionary <string, object> result = Conf.GetDictionary(UserDetailInfoUrl, Access_Token, "json"); string json = result["notice"].ToString(); Dictionary <string, object> notice = JsonHelper.Deserialize <Dictionary <string, object> >(json); if (result != null && result.Count > 0) { UserDetailInfo = new OSCUserDetailInfo() { uid = long.Parse(result["uid"].ToString()), name = result["name"].ToString(), gender = int.Parse(result["gender"].ToString()), province = result["province"].ToString(), city = result["city"].ToString(), platforms = ((string [])result["platforms"]).ToArray <string>(), expertise = ((string[])result["expertise"]).ToArray <string>(), joinTime = result["joinTime"].ToString(), lastLoginTime = result["lastLoginTime"].ToString(), portrait = result["portrait"].ToString(), fansCount = result["fansCount"].ToString(), favoriteCount = result["favoriteCount"].ToString(), followersCount = result["followersCount"].ToString(), replyCount = int.Parse(notice["replyCount"].ToString()), msgCount = int.Parse(notice["msgCount"].ToString()), newFansCount = int.Parse(notice["fansCount"].ToString()), referCount = int.Parse(notice["referCount"].ToString()) }; } return(result); } catch (Exception ex) { return(null); } }
//3.获取用户信息 #region 获取用户基本信息 /// <summary> /// 获取用户基本信息 /// </summary> /// <returns>用户基本信息</returns> public BaiduUserInfo GetUserInfo() { try { BaiduUserInfo model = null; Dictionary <string, object> result = Conf.GetDictionary(UserDetailInfoUrl, Access_Token, "json"); if (result != null && result.Count > 0) { this.UID = result["userid"].ToString(); //当前登录用户的数字ID this.UName = result["username"].ToString(); //当前登录用户的用户名,值可能为空 this.Portrait = result["portrait"].ToString(); //当前登录用户的头像 model = new BaiduUserInfo() { userid = result["userid"].ToString(), //当前登录用户的数字ID username = result["username"].ToString(), //当前登录用户的用户名,值可能为空 blood = result["blood"].ToString(), //血型 figure = result["figure"].ToString(), //体型 portrait = result["portrait"].ToString(), //当前登录用户的头像 birthday = result["birthday"].ToString(), //生日,以yyyy-mm-dd格式显示 marriage = result["marriage"].ToString(), //婚姻状况 sex = result["sex"].ToString(), //性别 constellation = result["constellation"].ToString(), //星座 education = result["education"].ToString(), //学历 trade = result["trade"].ToString(), //当前职业 is_bind_mobile = result["is_bind_mobile"].ToString(), job = result["job"].ToString() //职位 }; this.UserInfo = model; } return(model); } catch (Exception ex) { throw ex; } }