コード例 #1
0
 /// <summary>
 /// 获取粉丝列表
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public static SinaMUserList GetFollowerList(long id)
 {
     try
     {
         oAuthSina oauth = SinaBase.oAuth();
         SinaApiService sina = new SinaApiService();
         string json = sina.followers(oauth, id);
         return HttpUtil.ParseJson<SinaMUserList>(json);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
 /// <summary>
 /// 分页获取关注人
 /// </summary>
 /// <param name="id"></param>
 /// <param name="cursor"></param>
 /// <returns></returns>
 public static SinaMUserList GetFriendList(long id, int cursor)
 {
     try
     {
         oAuthSina oauth = SinaBase.oAuth();
         SinaApiService sina = new SinaApiService();
         string json = sina.friends(oauth, id, null, 50, cursor);
         return HttpUtil.ParseJson<SinaMUserList>(json);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
 /// <summary>
 /// 根据微博ID获取单条微博内容
 /// </summary>
 /// <param name="id">需要获取的微博ID。</param>
 /// <returns></returns>
 public static SinaMStatus Show(long id)
 {
     try
     {
         oAuthSina oauth = SinaBase.oAuth();
         SinaApiService sina = new SinaApiService();
         string json = sina.statuses_show(oauth, id);
         return HttpUtil.ParseJson<SinaMStatus>(json);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #4
0
 /// <summary>
 /// 取消关注一个用户
 /// </summary>
 /// <param name="uid">需要关注的用户</param>
 /// <returns></returns>
 public static bool FriendshipsDestroy(long uid)
 {
     try
     {
         oAuthSina oauth = SinaBase.oAuth();
         SinaApiService sina = new SinaApiService();
         string json = sina.friendships_destroy(oauth);
         var user = HttpUtil.ParseJson<SinaMUser>(json);
         return user != null && user.id > 0;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #5
0
 /// <summary>
 /// 发送微博信息(带图片)
 /// </summary>
 /// <param name="strSatus">信息内容</param>
 /// <param name="filePath">图片实际地址</param>
 public static bool Update(string strStatus, string filePath)
 {
     try
     {
         oAuthSina oauth = SinaBase.oAuth();
         SinaApiService sina = new SinaApiService();
         string json = sina.statuses_upload(oauth, strStatus, filePath);
         var status = HttpUtil.ParseJson<SinaMStatus>(json);
         return status != null && status.id > 0;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #6
0
 /// <summary>
 /// 批量获取用户的基本信息
 /// <para>高级接口(需要授权)</para>
 /// </summary>
 /// <param name="uids">需要查询的用户ID</param>
 /// <returns></returns>
 public static SinaMUserList GetUsersShowBatch(string[] ids)
 {
     try
     {
         oAuthSina oauth = SinaBase.oAuth();
         SinaApiService sina = new SinaApiService();
         long uid = GetUserId();
         string json = sina.users_show_batch(oauth, ids);
         return HttpUtil.ParseJson<SinaMUserList>(json);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #7
0
        /// <summary>
        /// OAuth授权之后,获取授权用户的UID
        /// <para>1. 用户OAuth授权之后获取用户UID,作用相当于旧版接口的(account/verify_credentials)</para>
        /// <para>2. 此接口不计入访问频次中</para>
        /// </summary>
        /// <returns></returns>
        public static long GetUserId()
        {
            try
            {
                oAuthSina oauth = SinaBase.oAuth();
                SinaApiService sina = new SinaApiService();
                Dictionary<string, object> dicUser = HttpUtil.ParseJson<Dictionary<string, object>>(sina.account_get_uid(oauth));
                long user_id = long.TryParse(HttpUtil.GetDicValue(dicUser, "uid"), out user_id) ? user_id : 0;
                return user_id;

            }
            catch (Exception ex)
            {
                ApiLogHelper.Append(ex);
                throw ex;
            }
        }
コード例 #8
0
 /// <summary>
 /// 获取指定用户信息
 /// </summary>
 /// <param name="uid">用户Id</param>
 /// <returns></returns>
 public static SinaMUser GetUser(long uid)
 {
     try
     {
         oAuthSina oauth = SinaBase.oAuth();
         SinaApiService sina = new SinaApiService();
         string json = sina.users_show(oauth, uid);
         return HttpUtil.ParseJson<SinaMUser>(json);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #9
0
 /// <summary>
 /// 返回用户最新发表的微博消息列表
 /// </summary>
 /// <returns></returns>
 public static SinaMStatusList UserTimeLine()
 {
     try
     {
         oAuthSina oauth = SinaBase.oAuth();
         SinaApiService sina = new SinaApiService();
         string json = sina.statuses_user_timeline(oauth);
         return HttpUtil.ParseJson<SinaMStatusList>(json);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }