Esempio n. 1
0
        public void GetFollowingUserListInternal(string id, int start, int count, GetFollowingUserListCompleteHandler handler)
        {
            String url = String.Format("https://api.douban.com/shuo/v2/users/{0}/following?start={1}&count={2}", id, start, count);
            WebClient client = new WebClient();

            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler((e1, e2) =>
            {
                try
                {
                    String result = e2.Result;
                    GetFollowingUserListEventArgs args = new GetFollowingUserListEventArgs();
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List<FollowingUserInfo>));
                    List<FollowingUserInfo> list = ser.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(result))) as List<FollowingUserInfo>;
                    if (list != null && list.Count != 0)
                    {
                        foreach (FollowingUserInfo info in list)
                        {
                            if (info.screen_name != "[已注销]")
                            {
                                m_friendList.Add(info);
                            }
                        }
                        GetFollowingUserListInternal(id, start + FETCH_COUNT, FETCH_COUNT, handler);
                    }
                    else
                    {
                        args.userList = m_friendList;
                        args.errorCode = DoubanSdkErrCode.SUCCESS;
                        handler(args);
                    }
                }
                catch (System.Exception ex)
                {
                    GetFollowingUserListEventArgs args = new GetFollowingUserListEventArgs();
                    args.userList = null;
                    args.errorCode = DoubanSdkErrCode.SERVER_ERR;
                    handler(args);
                }
            });
            client.DownloadStringAsync(new Uri(url));
        }
Esempio n. 2
0
 // 豆瓣的好友API虽然没说start和count的事,但是其实他们是启作用的
 public void GetFollowingUserList(string id, GetFollowingUserListCompleteHandler handler)
 {
     m_friendList.Clear();
     GetFollowingUserListInternal(id, 0, FETCH_COUNT, handler);
 }
Esempio n. 3
0
 public void GetFollowingUserList(String id, GetFollowingUserListCompleteHandler handler)
 {
     if (m_userAPI == null)
         m_userAPI = new UserAPI();
     m_userAPI.GetFollowingUserList(id, handler);
 }