当前位置: 首页>>代码示例>>C#>>正文


C# TwitterParametersCollection.EnsureEitherOr方法代码示例

本文整理汇总了C#中TwitterParametersCollection.EnsureEitherOr方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterParametersCollection.EnsureEitherOr方法的具体用法?C# TwitterParametersCollection.EnsureEitherOr怎么用?C# TwitterParametersCollection.EnsureEitherOr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TwitterParametersCollection的用法示例。


在下文中一共展示了TwitterParametersCollection.EnsureEitherOr方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReportUserForSpam

        /// <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>());
        }
开发者ID:gerryaobrien,项目名称:BoxKite.Twitter,代码行数:21,代码来源:ReportExtensions.cs

示例2: GetFollowersIDs

        /// <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>());
        }
开发者ID:nickhodge,项目名称:BoxKite.Twitter,代码行数:22,代码来源:FriendsFollowerExtensions.cs

示例3: GetLists

        /// <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>());
        }
开发者ID:gerryaobrien,项目名称:BoxKite.Twitter,代码行数:22,代码来源:ListExtensions.cs

示例4: GetUserProfile

        /// <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>());
        }
开发者ID:nickhodge,项目名称:BoxKite.Twitter,代码行数:20,代码来源:UsersExtensions.cs

示例5: GetFriendships

        /// <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>());
        }
开发者ID:nickhodge,项目名称:BoxKite.Twitter,代码行数:22,代码来源:FriendsFollowerExtensions.cs

示例6: GetFollowersList

        /// <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>());
        }
开发者ID:nickhodge,项目名称:BoxKite.Twitter,代码行数:26,代码来源:FriendsFollowerExtensions.cs

示例7: ChangeFriendship

        /// <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>());
        }
开发者ID:nickhodge,项目名称:BoxKite.Twitter,代码行数:24,代码来源:FriendsFollowerExtensions.cs

示例8: DeleteUsersFromList

        /// <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());
        }
开发者ID:gerryaobrien,项目名称:BoxKite.Twitter,代码行数:28,代码来源:ListExtensions.cs

示例9: GetUsersDetailsFull

        /// <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>());
        }
开发者ID:nickhodge,项目名称:BoxKite.Twitter,代码行数:22,代码来源:UsersExtensions.cs

示例10: DeleteUserBlock

        /// <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>());
        }
开发者ID:nickhodge,项目名称:BoxKite.Twitter,代码行数:21,代码来源:UsersExtensions.cs


注:本文中的TwitterParametersCollection.EnsureEitherOr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。