示例#1
0
        //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);
            }
        }
示例#2
0
 //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;
     }
 }