本文整理汇总了C#中TwitterParametersCollection.CreateCollection方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterParametersCollection.CreateCollection方法的具体用法?C# TwitterParametersCollection.CreateCollection怎么用?C# TwitterParametersCollection.CreateCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwitterParametersCollection
的用法示例。
在下文中一共展示了TwitterParametersCollection.CreateCollection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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>());
}
示例2: 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>());
}
示例3: 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());
}
示例4: GetTweetsFull
/// <summary>
/// Returns fully-hydrated tweets for up to 100 tweets per request, as specified by comma-separated values passed to the user_id and/or screen_name parameters.
/// </summary>
/// <param name="tweetIds">up to 100 are allowed in a single request.</param>
/// <returns>Observable List of full tweets</returns>
/// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/lookup </remarks>
public static async Task<TwitterResponseCollection<Tweet>> GetTweetsFull(this IUserSession session, IEnumerable<long> tweetIds = null)
{
var parameters = new TwitterParametersCollection();
parameters.Create(include_entities: true);
parameters.CreateCollection(tweetids: tweetIds);
return await session.PostAsync(TwitterApi.Resolve("/1.1/statuses/lookup.json"), parameters)
.ContinueWith(c => c.MapToMany<Tweet>());
}