/// <summary> /// Returns a map of the available size variations of the specified user's profile banner. /// </summary> /// <param name="screenName">The screen name of the user for whom to return results for.</param> /// <param name="userId">The ID of the user for whom to return results for.</param> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/users/profile_banner </remarks> public static async Task <ProfileBanners> GetProfileBanners(this IUserSession session, string screenName = "", long userId = 0) { var parameters = new TwitterParametersCollection(); parameters.Create(include_entities: true, skip_status: true, screen_name: screenName, user_id: userId); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return(session.MapParameterError <ProfileBanners>( "Either screen_name or user_id required")); } return(await session.GetAsync(TwitterApi.Resolve("/1.1/users/profile_banner.json"), parameters) .ContinueWith(c => c.MapToSingle <ProfileBanners>())); }
/// <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> /// 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 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> /// Report the specified user as a spam account to Twitter. Additionally performs the equivalent of POST blocks/create on behalf of the authenticated user. /// </summary> /// <param name="screenName">The ID or screen_name of the user you want to report as a spammer. Helpful for disambiguating when a valid screen name is also a user ID.</param> /// <param name="userId">The ID of the user you want to report as a spammer. Helpful for disambiguating when a valid user ID is also a valid screen name.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/users/report_spam </remarks> public async static Task<User> ReportUserForSpam(this IUserSession session, string screenName="", int userId=0) { var parameters = new TwitterParametersCollection(); parameters.Create(screen_name: screenName, 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.PostAsync(TwitterApi.Resolve("/1.1/users/report_spam.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> /// Report the specified user as a spam account to Twitter. Additionally performs the equivalent of POST blocks/create on behalf of the authenticated user. /// </summary> /// <param name="screenName">The ID or screen_name of the user you want to report as a spammer. Helpful for disambiguating when a valid screen name is also a user ID.</param> /// <param name="userId">The ID of the user you want to report as a spammer. Helpful for disambiguating when a valid user ID is also a valid screen name.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/users/report_spam </remarks> public async static Task <User> ReportUserForSpam(this IUserSession session, string screenName = "", int userId = 0) { var parameters = new TwitterParametersCollection(); parameters.Create(screen_name: screenName, 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.PostAsync(TwitterApi.Resolve("/1.1/users/report_spam.json"), parameters) .ContinueWith(c => c.MapToSingle <User>())); }
/// <summary> /// Returns the relationships of the authenticating user to the comma-separated list of up to 100 screen_names or user_ids provided. Values for connections can be: following, following_requested, followed_by, none. /// </summary> /// <param name="screenNames">list of screen_names to check</param> /// <param name="userIds">list of user_ids to check against</param> /// <returns></returns> /// <remarks> ref : https://dev.twitter.com/docs/api/1.1/get/friendships/lookup </remarks> public async static Task<TwitterResponseCollection<FriendshipLookupResponse>> GetFriendships(this IUserSession session, IEnumerable<string> screenNames = null, IEnumerable<long> userIds = null) { var parameters = new TwitterParametersCollection(); parameters.CreateCollection(screen_names: screenNames, user_ids:userIds); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return session.MapParameterError<TwitterResponseCollection<FriendshipLookupResponse>>( "Either screen_names or user_ids required"); } var url = TwitterApi.Resolve("/1.1/friendships/lookup.json"); return await session.GetAsync(url, parameters) .ContinueWith(f => f.MapToMany<FriendshipLookupResponse>()); }
/// <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>())); }
/// <summary> /// Allows one to enable or disable retweets and device notifications from the specified user. /// </summary> /// <param name="screenName">The screen name of the user</param> /// <param name="user_id">The ID of the user</param> /// <param name="device">Enable/disable device notifications from the target user.</param> /// <param name="retweets">Enable/disable retweets from the target user.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/friendships/update </remarks> public async static Task <UserStatus> ChangeFriendship(this IUserSession session, string screenName = "", int user_id = 0, bool device = false, bool retweets = false) { var parameters = new TwitterParametersCollection(); parameters.Create(screen_name: screenName, user_id: user_id, device: device, retweets: retweets); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return(session.MapParameterError <UserStatus>( "Either screen_name or user_id required")); } return(await session.PostAsync(TwitterApi.Resolve("/1.1/friendships/update.json"), parameters) .ContinueWith(c => c.MapToSingle <UserStatus>())); }
/// <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> /// Returns the relationships of the authenticating user to the comma-separated list of up to 100 screen_names or user_ids provided. Values for connections can be: following, following_requested, followed_by, none. /// </summary> /// <param name="screenNames">list of screen_names to check</param> /// <param name="userIds">list of user_ids to check against</param> /// <returns></returns> /// <remarks> ref : https://dev.twitter.com/docs/api/1.1/get/friendships/lookup </remarks> public async static Task <TwitterResponseCollection <FriendshipLookupResponse> > GetFriendships(this IUserSession session, IEnumerable <string> screenNames = null, IEnumerable <long> userIds = null) { var parameters = new TwitterParametersCollection(); parameters.CreateCollection(screen_names: screenNames, user_ids: userIds); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return(session.MapParameterError <TwitterResponseCollection <FriendshipLookupResponse> >( "Either screen_names or user_ids required")); } var url = TwitterApi.Resolve("/1.1/friendships/lookup.json"); return(await session.GetAsync(url, parameters) .ContinueWith(f => f.MapToMany <FriendshipLookupResponse>())); }
/// <summary> /// Removes multiple members from a list, by specifying a comma-separated list of member ids or screen names. The authenticated user must own the list to be able to remove members from it. /// </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="screenNames">list of screen names, up to 100 are allowed in a single request.</param> /// <param name="userIds">list of user IDs, up to 100 are allowed in a single request.</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/post/lists/members/destroy_all </remarks> public static async Task <TwitterSuccess> DeleteUsersFromList(this IUserSession session, long listId = 0, string slug = "", IEnumerable <string> screenNames = null, IEnumerable <long> userIds = null, string ownerScreenName = "", long ownerId = 0) { var parameters = new TwitterParametersCollection(); parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName); parameters.CreateCollection(screen_names: screenNames, user_ids: userIds); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return(session.MapParameterError <TwitterSuccess>( "Either screen_names or user_ids required")); } return(await session.PostAsync(TwitterApi.Resolve("/1.1/lists/members/destroy_all.json"), parameters) .ContinueWith(c => c.MapToTwitterSuccess())); }
/// <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 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>()); }
/// <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> /// Allows one to enable or disable retweets and device notifications from the specified user. /// </summary> /// <param name="screenName">The screen name of the user</param> /// <param name="user_id">The ID of the user</param> /// <param name="device">Enable/disable device notifications from the target user.</param> /// <param name="retweets">Enable/disable retweets from the target user.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/friendships/update </remarks> public async static Task<UserStatus> ChangeFriendship(this IUserSession session, string screenName = "", int user_id = 0, bool device=false, bool retweets=false) { var parameters = new TwitterParametersCollection(); parameters.Create(screen_name: screenName, user_id: user_id,device:device,retweets:retweets); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return session.MapParameterError<UserStatus>( "Either screen_name or user_id required"); } return await session.PostAsync(TwitterApi.Resolve("/1.1/friendships/update.json"), parameters) .ContinueWith(c => c.MapToSingle<UserStatus>()); }
/// <summary> /// Removes multiple members from a list, by specifying a comma-separated list of member ids or screen names. The authenticated user must own the list to be able to remove members from it. /// </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="screenNames">list of screen names, up to 100 are allowed in a single request.</param> /// <param name="userIds">list of user IDs, up to 100 are allowed in a single request.</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/post/lists/members/destroy_all </remarks> public static async Task<TwitterSuccess> DeleteUsersFromList(this IUserSession session, long listId=0, string slug="", IEnumerable<string> screenNames=null, IEnumerable<long> userIds=null, string ownerScreenName = "", long ownerId = 0) { var parameters = new TwitterParametersCollection(); parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName); parameters.CreateCollection(screen_names:screenNames, user_ids:userIds); if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse()) { return session.MapParameterError<TwitterSuccess>( "Either screen_names or user_ids required"); } return await session.PostAsync(TwitterApi.Resolve("/1.1/lists/members/destroy_all.json"), parameters) .ContinueWith(c => c.MapToTwitterSuccess()); }
/// <summary> /// Un-blocks the user specified in the ID parameter for the authenticating user. Returns the un-blocked user in the requested format when successful. If relationships existed before the block was instated, they will not be restored. /// </summary> /// <param name="screenName">The screen name of the potentially blocked user.</param> /// <param name="userId">The ID of the potentially blocked user.</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/blocks/destroy </remarks> public static async Task<User> DeleteUserBlock(this IUserSession session, string screenName = "", long userId = 0) { var parameters = new TwitterParametersCollection(); parameters.Create(include_entities: true, skip_status: true, screen_name: screenName, 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.PostAsync(TwitterApi.Resolve("/1.1/blocks/destroy.json"), parameters) .ContinueWith(c => c.MapToSingle<User>()); }