Class TwitterClient
Base client to do all your requests
Inheritance
Implements
Inherited Members
Namespace: TwitterSharp.Client
Assembly: TwitterSharp.dll
Syntax
public class TwitterClient : IDisposable
Constructors
| Improve this Doc View SourceTwitterClient(String)
Create a new instance of the client
Declaration
public TwitterClient(string bearerToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | bearerToken | Bearer token generated from https://developer.twitter.com/ |
Properties
| Improve this Doc View SourceIsTweetStreaming
Declaration
public static bool IsTweetStreaming { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceAddTweetStreamAsync(StreamRequest[])
Adds rules for the tweets/search/stream endpoint, which could be subscribed with the NextTweetStreamAsync(Action<Tweet>, TweetSearchOptions) method. No disconnection needed to add/remove rules using rules endpoint.
Declaration
public async Task<StreamInfo[]> AddTweetStreamAsync(params StreamRequest[] request)
Parameters
Type | Name | Description |
---|---|---|
StreamRequest[] | request | The rules to be added |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<StreamInfo[]> | The added rule |
CancelTweetStream(Boolean)
Closes the tweet stream started by NextTweetStreamAsync(Action<Tweet>, TweetSearchOptions).
Declaration
public void CancelTweetStream(bool force = true)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | force | If true, the stream will be closed immediately. With falls the thread had to wait for the next keep-alive signal (every 20 seconds) |
DeleteTweetStreamAsync(String[])
Removes a rule for the tweets/search/stream endpoint, which could be subscribed with the NextTweetStreamAsync(Action<Tweet>, TweetSearchOptions) method. No disconnection needed to add/remove rules using rules endpoint.
Declaration
public async Task<int> DeleteTweetStreamAsync(params string[] ids)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | ids | Id of the rules to be removed |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | The number of deleted rules |
Dispose()
Declaration
public void Dispose()
GetFollowersAsync(String, UserSearchOptions)
Get the follower of an user
Declaration
public async Task<Follow> GetFollowersAsync(string id, UserSearchOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | ID of the user |
UserSearchOptions | options |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Follow> |
GetFollowingAsync(String, UserSearchOptions)
Get the following of an user
Declaration
public async Task<Follow> GetFollowingAsync(string id, UserSearchOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | ID of the user |
UserSearchOptions | options |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Follow> |
GetInfoTweetStreamAsync()
Declaration
public async Task<StreamInfo[]> GetInfoTweetStreamAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<StreamInfo[]> |
GetTweetAsync(String, TweetSearchOptions)
Get a tweet given its ID
Declaration
public async Task<Tweet> GetTweetAsync(string id, TweetSearchOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | ID of the tweet |
TweetSearchOptions | options |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Tweet> |
GetTweetsAsync(String[], TweetSearchOptions)
Get a list of tweet given their IDs
Declaration
public async Task<Tweet[]> GetTweetsAsync(string[] ids, TweetSearchOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | ids | All the IDs you want the tweets of |
TweetSearchOptions | options |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Tweet[]> |
GetTweetsFromUserIdAsync(String, TweetSearchOptions)
Get the latest tweets of an user
Declaration
public async Task<Tweet[]> GetTweetsFromUserIdAsync(string userId, TweetSearchOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | userId | Username of the user you want the tweets of |
TweetSearchOptions | options |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Tweet[]> |
GetUserAsync(String, UserSearchOptions)
Get an user given his username
Declaration
public async Task<User> GetUserAsync(string username, UserSearchOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | Username of the user you want information about |
UserSearchOptions | options |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<User> |
GetUserByIdAsync(String, UserSearchOptions)
Get an user given his ID
Declaration
public async Task<User> GetUserByIdAsync(string id, UserSearchOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | ID of the user you want information about |
UserSearchOptions | options |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<User> |
GetUsersAsync(String[], UserSearchOptions)
Get a list of users given their usernames
Declaration
public async Task<User[]> GetUsersAsync(string[] usernames, UserSearchOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | usernames | Usernames of the users you want information about |
UserSearchOptions | options |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<User[]> |
GetUsersByIdsAsync(String[], UserSearchOptions)
Get a list of user given their IDs
Declaration
public async Task<User[]> GetUsersByIdsAsync(string[] ids, UserSearchOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | ids | IDs of the user you want information about |
UserSearchOptions | options |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<User[]> |
NextTweetStreamAsync(Action<Tweet>, TweetSearchOptions)
The stream is only meant to be open one time. So calling this method multiple time will result in an exception. For changing the rules with AddTweetStreamAsync(StreamRequest[]) and DeleteTweetStreamAsync(String[]) "No disconnection needed to add/remove rules using rules endpoint." It has to be canceled with CancelTweetStream(Boolean)
Declaration
public async Task NextTweetStreamAsync(Action<Tweet> onNextTweet, TweetSearchOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
System.Action<Tweet> | onNextTweet | The action which is called when a tweet arrives |
TweetSearchOptions | options | User properties send with the tweet |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Events
| Improve this Doc View SourceRateLimitChanged
Declaration
public event EventHandler<RateLimit> RateLimitChanged
Event Type
Type | Description |
---|---|
System.EventHandler<RateLimit> |