Esempio n. 1
0
        public List<TwitterUser> GetFollowers()
        {
            TwitterUser tuSelf = _service.GetUserProfile(
            new GetUserProfileOptions() { IncludeEntities = false, SkipStatus = false });
            //TODO: check if working
            ListFollowersOptions options = new ListFollowersOptions();
            options.UserId = tuSelf.Id;
            options.ScreenName = tuSelf.ScreenName;
            options.IncludeUserEntities = true;
            options.SkipStatus = false;
            options.Cursor = -1;
            List<TwitterUser> lstFollowers = new List<TwitterUser>();

            TwitterCursorList<TwitterUser> followers = _service.ListFollowers(options);

            // if the API call did not succeed
            if (followers == null)
            {
                ErrorHandling();
            }
            else
            {
                while (followers.NextCursor != null)
                {
                    //options.Cursor = followers.NextCursor;
                    //followers = m_twService.ListFollowers(options);

                    // if the API call did not succeed
                    if (followers == null)
                    {
                        ErrorHandling();
                    }
                    else
                    {
                        foreach (TwitterUser user in followers)
                        {
                            // do something with the user (I'm adding them to a List)
                            lstFollowers.Add(user);
                        }
                    }

                    // if there are more followers
                    if (followers.NextCursor != null &&
                        followers.NextCursor != 0)
                    {
                        // then advance the cursor and load the next page of results
                        options.Cursor = followers.NextCursor;
                        followers = _service.ListFollowers(options);
                    }
                    // otherwise, we're done!
                    else
                        break;
                }
            }
            return lstFollowers;
        }
Esempio n. 2
0
 static void ListFollowers()
 {
     var l = new ListFollowersOptions () { ScreenName = "EricNelson10", IncludeUserEntities = true, Cursor = -1, SkipStatus = true, };
     var result = service.ListFollowers(l, (users, response) =>
         {
             if (response.StatusCode == HttpStatusCode.OK)
             {
                 foreach (var user in users)
                 {
                     Console.WriteLine("Name: {0}, ScreenName: {1}", user.Name, user.ScreenName);
                 }
             }
         });
     result.AsyncWaitHandle.WaitOne();
 }
		public virtual void ListFollowers(ListFollowersOptions options, Action<TwitterCursorList<TwitterUser>, TwitterResponse> action)
		{
			var user_id = options.UserId;
			var screen_name = options.ScreenName;
			var cursor = options.Cursor;
			var skip_status = options.SkipStatus;
			var include_user_entities = options.IncludeUserEntities;
			
			WithHammock(action, "followers/list", FormatAsString, "?user_id=", user_id, "&screen_name=", screen_name, "&cursor=", cursor, "&skip_status=", skip_status, "&include_user_entities=", include_user_entities);
		}
		public virtual IAsyncResult BeginListFollowers(ListFollowersOptions options)
		{
			var user_id = options.UserId;
			var screen_name = options.ScreenName;
			var cursor = options.Cursor;
			var skip_status = options.SkipStatus;
			var include_user_entities = options.IncludeUserEntities;
				

			return BeginWithHammock<TwitterCursorList<TwitterUser>>(WebMethod.Get, "followers/list", FormatAsString, "?user_id=", user_id, "&screen_name=", screen_name, "&cursor=", cursor, "&skip_status=", skip_status, "&include_user_entities=", include_user_entities);
		}
		public virtual Task<TwitterResponse<TwitterCursorList<TwitterUser>>> ListFollowersAsync(ListFollowersOptions options)
		{
			var user_id = options.UserId;
			var screen_name = options.ScreenName;
			var cursor = options.Cursor;
			var skip_status = options.SkipStatus;
			var include_user_entities = options.IncludeUserEntities;
				
			
			return ExecuteRequest<TwitterCursorList<TwitterUser>>("followers/list", FormatAsString, "?user_id=", user_id, "&screen_name=", screen_name, "&cursor=", cursor, "&skip_status=", skip_status, "&include_user_entities=", include_user_entities);
		}
		public virtual Task<TwitterAsyncResult<TwitterCursorList<TwitterUser>>> ListFollowersAsync(ListFollowersOptions options)
		{
			var user_id = options.UserId;
			var screen_name = options.ScreenName;
			var count = options.Count;
			var cursor = options.Cursor;
			var skip_status = options.SkipStatus;
			var include_user_entities = options.IncludeUserEntities;
			
			return WithHammockTask<TwitterCursorList<TwitterUser>>(_client, "followers/list", FormatAsString, "?user_id=", user_id, "&screen_name=", screen_name, "&count=", count, "&cursor=", cursor, "&skip_status=", skip_status, "&include_user_entities=", include_user_entities);
		}