/// <summary>
        /// Runs a search for users similar to Find People button on Twitter.com. The results returned by people search on Twitter.com are the same as those returned by this API request.
        /// </summary>
        /// <param name="tokens">The tokens.</param>
        /// <param name="query">The query.</param>
        /// <param name="options">The options.</param>
        /// <param name="timeout">The timeout.</param>
        /// <param name="function">The function.</param>
        /// <returns></returns>
        public static IAsyncResult Search(OAuthTokens tokens, string query, UserSearchOptions options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterUserCollection>> function)
        {
            Func<OAuthTokens, string, UserSearchOptions, TwitterResponse<TwitterUserCollection>> methodToCall = TwitterUser.Search;

            return methodToCall.BeginInvoke(
                tokens,
                query,
                options,
                result =>
                {
                    result.AsyncWaitHandle.WaitOne(timeout);
                    try
                    {
                        function(methodToCall.EndInvoke(result).ToAsyncResponse());
                    }
                    catch (Exception ex)
                    {
                        function(new TwitterAsyncResponse<TwitterUserCollection>() { Result = RequestResult.Unknown, ExceptionThrown = ex });
                    }
                },
                null);
        }
Exemple #2
0
 /// <include file='TwitterUser.xml' path='TwitterUser/Search[@name="Common"]/*'/>
 /// <include file='TwitterUser.xml' path='TwitterUser/Search[@name="WithTokensAndOptions"]/*'/>
 public static async Task<TwitterResponse<TwitterUserCollection>> SearchAsync(string query, OAuthTokens tokens = null, UserSearchOptions options = null)
 {
     return await Core.CommandPerformer.PerformAction(new Commands.UserSearchCommand(tokens, query, options));
 } 
Exemple #3
0
        /// <include file='TwitterUser.xml' path='TwitterUser/Search[@name="Common"]/*'/>
        /// <include file='TwitterUser.xml' path='TwitterUser/Search[@name="WithTokensAndOptions"]/*'/>
        public static TwitterResponse<TwitterUserCollection> Search(OAuthTokens tokens, string query, UserSearchOptions options)
        {
            Commands.UserSearchCommand command = new Commands.UserSearchCommand(tokens, query, options);

            return Core.CommandPerformer.PerformAction(command);
        }
        /// <include file='TwitterUser.xml' path='TwitterUser/Search[@name="Common"]/*'/>
        /// <include file='TwitterUser.xml' path='TwitterUser/Search[@name="WithTokensAndOptions"]/*'/>
        public static TwitterResponse <TwitterUserCollection> Search(OAuthTokens tokens, string query, UserSearchOptions options)
        {
            Commands.UserSearchCommand command = new Commands.UserSearchCommand(tokens, query, options);

            return(Core.CommandPerformer.PerformAction(command));
        }
        /// <summary>
        /// Gets last 20 users
        /// </summary>
        /// <param name="search">Search string</param>
        /// <returns>TwitterUserInfo list</returns>
        public List<TwitterUserInfo> FindUsers(string search)
        {
            const int pageRowCount = 20;
            const int pageNumber = 0;

            try
            {
                Twitterizer.OAuthTokens tokens = GetOAuthTokens();

                UserSearchOptions options = new UserSearchOptions();
                options.Page = pageNumber;
                options.NumberPerPage = pageRowCount;

                TwitterResponse<TwitterUserCollection> userResponse = TwitterUser.Search(tokens, search, options);
                if (userResponse.Result == RequestResult.Success)
                {
                    TwitterUserCollection collection = userResponse.ResponseObject;
                    return MapUsers(userResponse.ResponseObject);
                }
                else
                    throw CreateException(userResponse.Result, userResponse.ErrorMessage);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
        }
 /// <summary>
 /// Runs a search for users similar to Find People button on Twitter.com. The results returned by people search on Twitter.com are the same as those returned by this API request.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="query">The query.</param>
 /// <param name="options">The options.</param>
 /// <param name="timeout">The timeout.</param>
 /// <param name="function">The function.</param>
 /// <returns></returns>
 public static IAsyncResult Search(OAuthTokens tokens, string query, UserSearchOptions options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterUserCollection>> function)
 {
     return AsyncUtility.ExecuteAsyncMethod(tokens, query, options, timeout, TwitterUser.Search, function);
 }
 /// <include file='TwitterUser.xml' path='TwitterUser/Search[@name="Common"]/*'/>
 /// <include file='TwitterUser.xml' path='TwitterUser/Search[@name="WithTokensAndOptions"]/*'/>
 public static async Task <TwitterResponse <TwitterUserCollection> > SearchAsync(string query, OAuthTokens tokens = null, UserSearchOptions options = null)
 {
     return(await Core.CommandPerformer.PerformAction(new Commands.UserSearchCommand(tokens, query, options)));
 }
 /// <summary>
 /// Runs a search for users similar to Find People button on Twitter.com. The results returned by people search on Twitter.com are the same as those returned by this API request.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="query">The query.</param>
 /// <param name="options">The options.</param>
 /// <param name="timeout">The timeout.</param>
 /// <param name="function">The function.</param>
 /// <returns></returns>
 public static IAsyncResult Search(OAuthTokens tokens, string query, UserSearchOptions options, TimeSpan timeout, Action <TwitterAsyncResponse <TwitterUserCollection> > function)
 {
     return(AsyncUtility.ExecuteAsyncMethod(tokens, query, options, timeout, TwitterUser.Search, function));
 }