本文整理汇总了C#中TwitterParametersCollection.Create方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterParametersCollection.Create方法的具体用法?C# TwitterParametersCollection.Create怎么用?C# TwitterParametersCollection.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwitterParametersCollection
的用法示例。
在下文中一共展示了TwitterParametersCollection.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDirectMessageSingle
/// <summary>
/// Returns a direct message sent to the authenticating user.
/// </summary>
/// <param name="Id">ID of direct message to return</param>
/// <returns>(awaitable) Get A DirectMessage sent/received the session's authenticated user</returns>
/// <remarks>ref: https://dev.twitter.com/docs/api/1.1/get/direct_messages/show </remarks>
public async static Task<DirectMessage> GetDirectMessageSingle(this IUserSession session, long Id)
{
var parameters = new TwitterParametersCollection();
parameters.Create(id: Id, full_text:true);
return await session.GetAsync(TwitterApi.Resolve("/1.1/direct_messages/show.json"), parameters)
.ContinueWith(c => c.MapToSingle<DirectMessage>());
}
示例2: GetVerifyCredentials
/// <summary>
/// Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not. Use this method to test if supplied user credentials are valid.
/// </summary>
/// <returns></returns>
public static async Task<User> GetVerifyCredentials(this IUserSession session)
{
var parameters = new TwitterParametersCollection();
parameters.Create(include_entities: true);
return await session.GetAsync(TwitterApi.Resolve("/1.1/account/verify_credentials.json"), parameters)
.ContinueWith(c => c.MapToSingle<User>());
}
示例3: GetUserTimeline
/// <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>());
}
示例4: GetRetweetsOfMe
/// <summary>
/// Returns the most recent tweets authored by the authenticating user that have been retweeted by others.
/// </summary>
/// <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 records to retrieve. Must be less than or equal to 100. If omitted, 20 will be assumed.</param>
/// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID.</param>
/// <returns></returns>
/// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/retweets_of_me </remarks>
public async static Task<TwitterResponseCollection<Tweet>> GetRetweetsOfMe(this IUserSession session, long sinceId = 0, long maxId = 0, int count = 20)
{
var parameters = new TwitterParametersCollection();
parameters.Create(include_entities: true, include_rts: true, count: count, since_id: sinceId, max_id: maxId);
return await session.GetAsync(TwitterApi.Resolve("/1.1/statuses/retweets_of_me.json"), parameters)
.ContinueWith(c => c.MapToMany<Tweet>());
}
示例5: DeleteUserFromList
/// <summary>
/// Removes the specified member from the list. The authenticated user must be the list's owner to remove members from the 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 to remove from the list. 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 remove from the list. 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/post/lists/members/destroy </remarks>
public static async Task<TwitterSuccess> DeleteUserFromList(this IUserSession session, long listId = 0, string slug = "",
long userId = 0, string screenName = "", string ownerScreenName = "", long ownerId = 0)
{
var parameters = new TwitterParametersCollection();
parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName, user_id: userId, screen_name: screenName);
return await session.PostAsync(TwitterApi.Resolve("/1.1/lists/members/destroy"), parameters)
.ContinueWith(c => c.MapToTwitterSuccess());
}
示例6: GetFavourites
/// <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>());
}
示例7: GetDirectMessagesSent
/// <summary>
/// Returns the most recent direct messages sent by the authenticating user.
/// </summary>
/// <param name="sinceId">Returns results with an ID greater than (that is, more recent than) the specified ID</param>
/// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID</param>
/// <param name="count">Specifies the number of direct messages to try and retrieve, up to a maximum of 200</param>
/// <returns>(awaitable) IEnumerable of DirectMessages Sent by the session's authenticated user</returns>
/// <remarks>ref: https://dev.twitter.com/docs/api/1.1/get/direct_messages/sent </remarks>
public async static Task<TwitterResponseCollection<DirectMessage>> GetDirectMessagesSent(this IUserSession session, long sinceId = 0, long maxId = 0, int count = 20)
{
var parameters = new TwitterParametersCollection();
parameters.Create(include_entities: true, count: count, since_id: sinceId,
max_id: maxId, full_text:true);
return await session.GetAsync(TwitterApi.Resolve("/1.1/direct_messages/sent.json"), parameters)
.ContinueWith(c => c.MapToMany<DirectMessage>());
}
示例8: DeleteFavourite
/// <summary>
/// https://dev.twitter.com/docs/api/1.1/post/favorites/destroy
/// Un-favourites a given tweet
/// </summary>
/// <param name="tweet">Tweet for to favourite</param>
/// <returns></returns>
public async static Task<Tweet> DeleteFavourite(this IUserSession session, Tweet tweet)
{
var parameters = new TwitterParametersCollection();
parameters.Create(id: tweet.Id);
var url = TwitterApi.Resolve("/1.1/favorites/destroy.json");
return await session.PostAsync(url, parameters)
.ContinueWith(c => c.MapToSingle<Tweet>());
}
示例9: GetListTimeline
/// <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>());
}
示例10: SendDirectMessage
/// <summary>
/// Sends a direct message sent to a user.
/// </summary>
/// <param name="text">Text to send to user</param>
/// <param name="screenName">Screen name of the recipient</param>
/// <returns></returns>
/// <remarks>ref: https://dev.twitter.com/docs/api/1.1/post/direct_messages/new </remarks>
public async static Task<DirectMessage> SendDirectMessage(this IUserSession session, string screenName, string text)
{
var parameters = new TwitterParametersCollection();
parameters.Create(include_entities:true, screen_name:screenName, text:text.TrimAndTruncate(140));
if (parameters.EnsureAllArePresent(new [] {"screen_name", "text"}).IsFalse())
{
return session.MapParameterError<DirectMessage>(
"Either screen_name and text required");
}
return await session.PostAsync(TwitterApi.Resolve("/1.1/direct_messages/new.json"), parameters)
.ContinueWith(c => c.MapToSingle<DirectMessage>());
}
示例11: 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>());
}
示例12: 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>());
}
示例13: 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>());
}
示例14: 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>());
}
示例15: ChangeSearchParameters
public TwitterParametersCollection ChangeSearchParameters(IEnumerable<string> track = null, IEnumerable<string> follow = null, IEnumerable<string> locations = null, string filterlevel = "none", string language = "en")
{
var parameters = new TwitterParametersCollection();
parameters.Create(stall_warnings: false, delimited: false);
if (track != null)
parameters.CreateCommaDelimitedList("track", track);
if (follow != null)
parameters.CreateCommaDelimitedList("follow", follow);
if (locations != null)
parameters.CreateCommaDelimitedList("locations", locations);
parameters.Add("filter_level", filterlevel);
parameters.Add("language", language);
return parameters;
}