/// <summary> /// Returns detailed information about the relationship between two arbitrary users. /// </summary> /// <param name="sourceScreenName">The user_id of the subject user.</param> /// <param name="sourceId">The screen_name of the subject user.</param> /// <param name="targetId">The user_id of the target user.</param> /// <param name="targetScreenName">The screen_name of the target user.</param> /// <returns></returns> /// <remarks> ref: https://api.twitter.com/1.1/friendships/show.json </remarks> public async static Task <UserStatus> GetFriendship(this ITwitterSession session, string sourceScreenName = "", string targetScreenName = "", int sourceId = 0, int targetId = 0) { var parameters = new TwitterParametersCollection(); if (!string.IsNullOrWhiteSpace(sourceScreenName)) { parameters.Add("source_screen_name", sourceScreenName); } if (sourceId != 0) { parameters.Add("source_id", sourceId.ToString()); } if (!string.IsNullOrWhiteSpace(targetScreenName)) { parameters.Add("target_screen_name", targetScreenName); } if (targetId != 0) { parameters.Add("target_id", targetId.ToString()); } return(await session.GetAsync(TwitterApi.Resolve("/1.1/friendships/show.json"), parameters) .ContinueWith(c => c.MapToSingle <UserStatus>())); }
public async Task<bool> DoApiTest(ITwitterSession session, List<int> testSeq) { var successStatus = true; try { // 1 if (testSeq.Contains(1)) { ConsoleOutput.PrintMessage("ApiManagement\\GetCurrentAPIStatus", ConsoleColor.Gray); var currentapi = await session.GetCurrentApiStatus(); if (currentapi.OK) { foreach (var x in currentapi.APIRateStatuses) { ConsoleOutput.PrintMessage( String.Format("API on: {0} Calls: {1}/{2} Resets: {3}", x.Key, x.Value.Remaining, x.Value.Limit, x.Value.ResetTime )); } } else successStatus = false; } } catch (Exception e) { ConsoleOutput.PrintError(e.ToString()); return false; } return successStatus; }
// Map incorrect parameter errors internal static T MapParameterError <T>(this ITwitterSession s, string errorMessage) where T : new() { var responseMessage = new T(); var twitterControlMessage = new TwitterControlMessage { twitter_error_message = String.Format("Parameter Error: {0}", errorMessage) }; var boolType = new[] { typeof(bool) }; var tcmType = new[] { typeof(TwitterControlMessage) }; // find the property set method created by the compiler // and manually set the right params in the response var statusProperty = responseMessage.GetType().GetRuntimeMethod("set_twitterFaulted", boolType); if (statusProperty != null) { statusProperty.Invoke(responseMessage, new object[] { true }); } var tcmProperty = responseMessage.GetType().GetRuntimeMethod("set_twitterControlMessage", tcmType); if (tcmProperty != null) { tcmProperty.Invoke(responseMessage, new object[] { twitterControlMessage }); } return(responseMessage); }
public async Task <bool> DoApiTest(ITwitterSession session, List <int> testSeq) { var successStatus = true; try { // 1 if (testSeq.Contains(1)) { ConsoleOutput.PrintMessage("ApiManagement\\GetCurrentAPIStatus", ConsoleColor.Gray); var currentapi = await session.GetCurrentApiStatus(); if (currentapi.OK) { foreach (var x in currentapi.APIRateStatuses) { ConsoleOutput.PrintMessage( String.Format("API on: {0} Calls: {1}/{2} Resets: {3}", x.Key, x.Value.Remaining, x.Value.Limit, x.Value.ResetTime)); } } else { successStatus = false; } } } catch (Exception e) { ConsoleOutput.PrintError(e.ToString()); return(false); } return(successStatus); }
/// <summary> /// Returns the current rate limits for methods belonging to the specified resource families. /// </summary> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/application/rate_limit_status </remarks> public static async Task <ApiRateStatusResponse> GetCurrentApiStatus(this ITwitterSession session) { var parameters = new SortedDictionary <string, string>(); var url = TwitterApi.Resolve("/1.1/application/rate_limit_status.json"); var c = session.GetAsync(url, parameters); return(await c.MapToApiRateLimits()); }
/// <summary> /// Access the users in a given category of the Twitter suggested user list. /// </summary> /// <param name="slug">The short name of list or a category returned by GetSuggestedList</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/users/suggestions/%3Aslug </remarks> public static async Task <SuggestedUsers> GetSuggestedUsers(this ITwitterSession session, string slug) { var parameters = new TwitterParametersCollection(); var url = TwitterApi.Resolve("/1.1/users/suggestions/{0}.json", slug); return(await session.GetAsync(url, parameters) .ContinueWith(c => c.MapToSingle <SuggestedUsers>())); }
/// <summary> /// Returns the specified list. Private lists will only be shown if the authenticated user owns the specified list. /// </summary> /// <param name="listId">The numerical id of the list.</param> /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param> /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param> /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/show </remarks> public static async Task <TwitterList> GetList(this ITwitterSession session, long listId, string slug, string ownerScreenName = "", long ownerId = 0) { var parameters = new TwitterParametersCollection(); parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName); return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/show.json"), parameters) .ContinueWith(c => c.MapToSingle <TwitterList>())); }
/// <summary> /// Returns the lists owned by the specified Twitter user. Private lists will only be shown if the authenticated user is also the owner of the lists. /// </summary> /// <param name="screenName"></param> /// <param name="userId"></param> /// <param name="count"></param> /// <param name="cursor"></param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/ownerships </remarks> public static async Task <TwitterListCursored> GetListOwned(this ITwitterSession session, string screenName = "", long userId = 0, int count = 20, long cursor = -1) { var parameters = new TwitterParametersCollection(); parameters.Create(user_id: userId, screen_name: screenName, count: count, cursor: cursor); return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/ownerships.json"), parameters) .ContinueWith(c => c.MapToSingle <TwitterListCursored>())); }
/// <summary> /// Check if the specified user is a member of the specified list /// </summary> /// <param name="listId">The numerical id of the list.</param> /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param> /// <param name="userId">The ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.</param> /// <param name="screenName">The screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.</param> /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param> /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/members/show </remarks> public static async Task <User> IsUserOnList(this ITwitterSession session, long listId, string slug = "", long userId = 0, string screenName = "", string ownerScreenName = "", long ownerId = 0) { var parameters = new TwitterParametersCollection(); parameters.Create(user_id: userId, screen_name: screenName, list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName, skip_status: true, include_entities: true); return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/members/show.json"), parameters) .ContinueWith(c => c.MapToSingle <User>())); }
/// <summary> /// Returns the subscribers of the specified list. Private list subscribers will only be shown if the authenticated user owns the specified list. /// </summary> /// <param name="listId">The numerical id of the list.</param> /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param> /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param> /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param> /// <param name="cursor">Breaks the results into pages.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/subscribers </remarks> public static async Task <UserListDetailedCursored> GetListSubscribers(this ITwitterSession session, long listId, string slug = "", long ownerId = 0, string ownerScreenName = "", long cursor = -1) { var parameters = new TwitterParametersCollection(); parameters.Create(skip_status: false, include_entities: true, cursor: cursor, list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName); return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/subscribers.json"), parameters) .ContinueWith(c => c.MapToSingle <UserListDetailedCursored>())); }
/// <summary> /// Gets the Retweets of a particular tweet /// </summary> /// <param name="tweetId"></param> /// <param name="count"></param> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/%3Aid </remarks> public async static Task <TwitterResponseCollection <Tweet> > GetRetweets(this ITwitterSession session, long tweetId, int count = 20) { var parameters = new TwitterParametersCollection { { "count", count.ToString() }, }; var path = TwitterApi.Resolve("/1.1/statuses/retweets/{0}.json", tweetId); return(await session.GetAsync(path, parameters) .ContinueWith(c => c.MapToMany <Tweet>())); }
/// <summary> /// https://dev.twitter.com/docs/api/1.1/get/favorites/list /// Returns the count most recent Tweets favorited by the authenticating or specified user. /// If user_id and screen_name is left blank, current auth'd user favourites are returned /// Entities are always returned /// </summary> /// <param name="userId">The ID of the user for whom to return results for</param> /// <param name="screenName">The screen name of the user for whom to return results for</param> /// <param name="sinceId">Returns results with an ID greater than</param> /// <param name="count">Specifies the number of records to retrieve. Must be less than or equal to 200. Defaults to 20.</param> /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified </param> /// <returns></returns> public async static Task <TwitterResponseCollection <Tweet> > GetFavourites(this ITwitterSession session, string screenName = "", int userId = 0, long sinceId = 0, long maxId = 0, int count = 20) { var parameters = new TwitterParametersCollection(); parameters.Create(count: count, include_entities: true, since_id: sinceId, max_id: maxId, user_id: userId, screen_name: screenName); var url = TwitterApi.Resolve("/1.1/favorites/list.json"); return(await session.GetAsync(url, parameters) .ContinueWith(c => c.MapToMany <Tweet>())); }
/// <summary> /// Returns the lists the specified user has been added to. If user_id or screen_name are not provided the memberships for the authenticating user are returned. /// </summary> /// <param name="userId">The ID of the user for whom to return results for.</param> /// <param name="screenName">The screen name of the user for whom to return results for.</param> /// <param name="cursor">Breaks the results into pages. Provide a value of -1 to begin paging.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/memberships </remarks> public static async Task <UserInListCursored> GetListMembershipForUser(this ITwitterSession session, long userId = 0, string screenName = "", long cursor = -1) { var parameters = new TwitterParametersCollection { { "filter_to_owned_lists", false.ToString() }, }; parameters.Create(cursor: cursor, user_id: userId, screen_name: screenName); return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/memberships.json"), parameters) .ContinueWith(c => c.MapToSingle <UserInListCursored>())); }
/// <summary> /// Gets a particular Tweet /// </summary> /// <param name="tweetId">The tweet ID to return</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/show/%3Aid </remarks> public async static Task <Tweet> GetTweet(this ITwitterSession session, long tweetId) { var parameters = new TwitterParametersCollection { { "trim_user", false.ToString() }, { "include_my_retweet", true.ToString() }, }; parameters.Create(id: tweetId, include_entities: true); return(await session.GetAsync(TwitterApi.Resolve("/1.1/statuses/show.json"), parameters) .ContinueWith(c => c.MapToSingle <Tweet>())); }
/// <summary> /// Returns the locations that Twitter has trending topic information for, closest to a specified location. /// </summary> /// <param name="latitude">If provided with a long parameter the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair.</param> /// <param name="longitude">If provided with a lat parameter the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/trends/closest </remarks> public static async Task <TwitterResponseCollection <TrendsAvailableLocationsResponse> > GetTrendsByLocation( this ITwitterSession session, double latitude = 0.0, double longitude = 0.0) { var parameters = new TwitterParametersCollection { { "lat", latitude.ToString() }, { "long", longitude.ToString() }, }; return(await session.GetAsync(TwitterApi.Resolve("/1.1/trends/closest.json"), parameters) .ContinueWith(c => c.MapToMany <TrendsAvailableLocationsResponse>())); }
/// <summary> /// Returns a variety of information about the user specified by the required user_id or screen_name parameter. The author's most recent Tweet will be returned inline when possible. /// </summary> /// <param name="screenName">The screen name of the user for whom to return results for. Either a id or screen_name is required for this method.</param> /// <param name="userId">The ID of the user for whom to return results for. Either an id or screen_name is required for this method.</param> /// <returns></returns> public static async Task <User> GetUserProfile(this ITwitterSession session, string screenName = "", long userId = 0) { var parameters = new TwitterParametersCollection(); parameters.Create(screen_name: screenName, include_entities: true, user_id: userId); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return(session.MapParameterError <User>( "Either screen_name or user_id required")); } return(await session.GetAsync(TwitterApi.Resolve("/1.1/users/show.json"), parameters) .ContinueWith(c => c.MapToSingle <User>())); }
/// <summary> /// Returns a cursored collection of user IDs following a particular user(otherwise known as their "followers") /// </summary> /// <param name="cursor">default is first page (-1) otherwise provide starting point</param> /// <param name="userId">screen_name or user_id must be provided</param> /// <param name="screenName">screen_name or user_id must be provided</param> /// <param name="count">how many to return default 500</param> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/followers/ids </remarks> public static async Task <FriendsFollowersIDsCursored> GetFollowersIDs(this ITwitterSession session, string screenName = "", int userId = 0, int count = 500, long cursor = -1) { var parameters = new TwitterParametersCollection(); parameters.Create(count: count, cursor: cursor, screen_name: screenName, user_id: userId); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return(session.MapParameterError <FriendsFollowersIDsCursored>( "Either screen_name or user_id required")); } return(await session.GetAsync(TwitterApi.Resolve("/1.1/followers/ids.json"), parameters) .ContinueWith(t => t.MapToSingle <FriendsFollowersIDsCursored>())); }
/// <summary> /// Returns all lists the authenticating or specified user subscribes to, including their own. The user is specified using the user_id or screen_name parameters. If no user is given, the authenticating user is used. /// </summary> /// <param name="userId">The ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.</param> /// <param name="screenName">The screen name of the user for whom to return results for.</param> /// <param name="reverse">Set this to true if you would like owned lists to be returned first.</param> /// <returns>(awaitable) IEnumerable Lists the authenticated user or screen_name subscribes to</returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/list </remarks> public static async Task <TwitterResponseCollection <TwitterList> > GetLists(this ITwitterSession session, long userId = 0, string screenName = "", bool reverse = false) { var parameters = new TwitterParametersCollection { { "reverse", reverse.ToString() } }; parameters.Create(screen_name: screenName, user_id: userId); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return(session.MapParameterError <TwitterResponseCollection <TwitterList> >( "Either screen_name or user_id required")); } return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/list.json"), parameters) .ContinueWith(c => c.MapToMany <TwitterList>())); }
/// <summary> /// dedicated API for running searches against the real-time index of recent Tweets. 6-9 days of historical data /// </summary> /// <param name="searchText">search query of 1,000 characters maximum, including operators. Queries may additionally be limited by complexity.</param> /// <param name="maxId"></param> /// <param name="sinceId"></param> /// <param name="untilDate">YYYY-MM-DD format</param> /// <param name="count">Tweets to return Default 20</param> /// <param name="searchResponseType">SearchResult.Mixed (default), SearchResult.Recent, SearchResult.Popular</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/search/tweets </remarks> public async static Task <SearchResponse> SearchFor(this ITwitterSession session, string searchText, SearchResultType searchResponseType, long maxId = 0, long sinceId = 0, string untilDate = "", int count = 20) { var parameters = new TwitterParametersCollection { { "q", searchText.TrimAndTruncate(1000).UrlEncode() }, { "result_type", SearchResultString(searchResponseType) }, }; parameters.Create(since_id: sinceId, max_id: maxId, count: count, include_entities: true); if (!string.IsNullOrWhiteSpace(untilDate)) { parameters.Add("until", untilDate); } return(await session.GetAsync(TwitterApi.Resolve("/1.1/search/tweets.json"), parameters) .ContinueWith(c => c.MapToSingle <SearchResponse>())); }
/// <summary> /// Returns a cursored collection of user objects for users following the specified user. /// Presently in most recent following first /// </summary> /// <param name="cursor">default is first page (-1) otherwise provide starting point</param> /// <param name="userId">screen_name or user_id must be provided</param> /// <param name="screenName">screen_name or user_id must be provided</param> /// <param name="count">how many to return default 500</param> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/followers/list </remarks> public async static Task <UserListDetailedCursored> GetFollowersList(this ITwitterSession session, string screenName = "", int userId = 0, int count = 20, long cursor = -1) { var parameters = new TwitterParametersCollection { { "include_user_entities", true.ToString() }, }; parameters.Create(count: count, cursor: cursor, screen_name: screenName, user_id: userId, skip_status: true); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return(session.MapParameterError <UserListDetailedCursored>( "Either screen_name or user_id required")); } return(await session.GetAsync(TwitterApi.Resolve("/1.1/followers/list.json"), parameters) .ContinueWith(t => t.MapToSingle <UserListDetailedCursored>())); }
/// <summary> /// Returns a timeline of tweets authored by members of the specified list. Retweets are included by default. /// </summary> /// <param name="listId">The numerical id of the list.</param> /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param> /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param> /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param> /// <param name="sinceId">Returns results with an ID greater than (that is, more recent than) the specified ID.</param> /// <param name="count">Specifies the number of results to retrieve per "page."</param> /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID.</param> /// <param name="includeRetweets">the list timeline will contain native retweets (if they exist) in addition to the standard stream of tweets.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/statuses </remarks> public static async Task <TwitterResponseCollection <Tweet> > GetListTimeline(this ITwitterSession session, long listId, string slug, long ownerId = 0, string ownerScreenName = "", long sinceId = 0, int count = 20, long maxId = 0, bool includeRetweets = true) { var parameters = new TwitterParametersCollection { { "include_rts", includeRetweets.ToString() }, }; parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName, since_id: sinceId, max_id: maxId); return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/statuses.json"), parameters) .ContinueWith(c => c.MapToMany <Tweet>())); }
/// <summary> /// Returns the top 10 trending topics for a specific WOEID, if trending information is available for it. /// </summary> /// <param name="placeId">The Yahoo! Where On Earth ID of the location to return trending information for. Global information is available by using 1 as the WOEID.</param> /// <param name="exclude">If true will remove all hashtags from the trends list.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/trends/place </remarks> public static async Task <TwitterResponseCollection <TrendsForPlaceResponse> > GetTrendsForPlace(this ITwitterSession session, int placeId = 1, bool exclude = false) { var parameters = new TwitterParametersCollection { { "id", placeId.ToString() } }; if (exclude) { parameters.Add("exclude", "hashtags"); } return(await session.GetAsync(TwitterApi.Resolve("/1.1/trends/place.json"), parameters) .ContinueWith(c => c.MapToMany <TrendsForPlaceResponse>())); }
/// <summary> /// Returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters. /// </summary> /// <param name="userId">The ID of the user for whom to return results for.</param> /// <param name="screenName">The screen name of the user for whom to return results for.</param> /// <param name="sinceId">Returns results with an ID greater than (that is, more recent than) the specified ID.</param> /// <param name="count">Specifies the number of tweets to try and retrieve, up to a maximum of 200 per distinct request</param> /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID.</param> /// <param name="excludeReplies">This parameter will prevent replies from appearing in the returned timeline. </param> /// <param name="includeRetweets">When set to false, the timeline will strip any native retweets</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline </remarks> public async static Task <TwitterResponseCollection <Tweet> > GetUserTimeline(this ITwitterSession session, string screenName = "", long userId = 0, long sinceId = 0, long maxId = 0, int count = 200, bool excludeReplies = true, bool includeRetweets = true) { var parameters = new TwitterParametersCollection(); parameters.Create(include_entities: true, include_rts: true, count: count, since_id: sinceId, max_id: maxId, screen_name: screenName); return(await session.GetAsync(TwitterApi.Resolve("/1.1/statuses/user_timeline.json"), parameters) .ContinueWith(c => c.MapToMany <Tweet>())); }
/// <summary> /// Returns the locations that Twitter has trending topic information for. /// </summary> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/trends/available </remarks> public static async Task <TwitterResponseCollection <TrendsAvailableLocationsResponse> > GetTrendsAvailableLocations(this ITwitterSession session) { var parameters = new TwitterParametersCollection(); return(await session.GetAsync(TwitterApi.Resolve("/1.1/trends/available.json"), parameters) .ContinueWith(c => c.MapToMany <TrendsAvailableLocationsResponse>())); }
/// <summary> /// Access to Twitter's suggested user list. This returns the list of suggested user categories. /// </summary> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/users/suggestions </remarks> public static async Task <TwitterResponseCollection <SuggestedUsers> > GetSuggestedLists(this ITwitterSession session) { var parameters = new TwitterParametersCollection(); return(await session.GetAsync(TwitterApi.Resolve("/1.1/users/suggestions.json"), parameters) .ContinueWith(c => c.MapToMany <SuggestedUsers>())); }
public GetAccessTokenViewModel(ITwitterSession session, IBus bus) { DisplayName = "Authorize Membus OnTweet to interact with Twitter on your behalf"; this.session = session; this.bus = bus; }
/// <summary> /// Returns fully-hydrated user objects for up to 100 users per request, as specified by comma-separated values passed to the user_id and/or screen_name parameters. /// </summary> /// <param name="screenNames">up to 100 are allowed in a single request.</param> /// <param name="userIds">up to 100 are allowed in a single request. </param> /// <returns>Observable List of full user details</returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/users/lookup </remarks> public static async Task <TwitterResponseCollection <User> > GetUsersDetailsFull(this ITwitterSession session, IEnumerable <string> screenNames = null, IEnumerable <long> userIds = null) { var parameters = new TwitterParametersCollection(); parameters.Create(include_entities: true); parameters.CreateCollection(screen_names: screenNames, user_ids: userIds); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return(session.MapParameterError <TwitterResponseCollection <User> >( "Either screen_names or user_ids required")); } return(await session.GetAsync(TwitterApi.Resolve("/1.1/users/lookup.json"), parameters).ContinueWith(c => c.MapToMany <User>())); }