Class GuestClient
ゲスト(未ログイン)として Twitter API と対話するクライアント。
public sealed class GuestClient : IRequestClient, IRawHttpSession, IDisposable
- Inheritance
-
GuestClient
- Implements
- Inherited Members
Remarks
2026 年現在、X はゲストアクセスを閉じています。 未ログインのリクエストには webpack マニフェストを
含まないページの殻しか返ってこないため、x-client-transaction-id のハンドシェイクが完了できず、
ActivateAsync() は InvalidSessionException を送出します。これはライブラリ側では直せません。
ログイン済みの Cookie を使う Client を利用してください。
Constructors
GuestClient(string, string?, HttpMessageHandler?)
public GuestClient(string language = "en-US", string? proxy = null, HttpMessageHandler? handler = null)
Parameters
languagestringAPI リクエストで使う言語コード。
proxystringプロキシの URL。
handlerHttpMessageHandler独自の HttpMessageHandler。
Properties
BaseHeaders
API リクエストの基本ヘッダー。
public Dictionary<string, string> BaseHeaders { get; }
Property Value
ClientTransaction
public ClientTransaction ClientTransaction { get; }
Property Value
Cookies
Cookie ジャー。
public CookieContainer Cookies { get; }
Property Value
Gql
public GqlClient Gql { get; }
Property Value
Http
実際に通信する HttpClient。
public HttpClient Http { get; }
Property Value
Language
API リクエストで使う言語コード。
public string Language { get; set; }
Property Value
Proxy
プロキシの URL。
public string? Proxy { get; }
Property Value
UserAgent
public string UserAgent { get; }
Property Value
V11
public V11Client V11 { get; }
Property Value
Methods
ActivateAsync()
ゲストトークンを取得してクライアントを有効化します。
public Task<string> ActivateAsync()
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetAsync(string, RequestOptions?)
public Task<ApiResponse> GetAsync(string url, RequestOptions? options = null)
Parameters
urlstringoptionsRequestOptions
Returns
GetCsrfToken()
Cookie 中の CSRF トークン(ct0)。無ければ null。
public string? GetCsrfToken()
Returns
GetTweetByIdAsync(string)
ID を指定してツイートを取得します。
public Task<GuestTweet?> GetTweetByIdAsync(string tweetId)
Parameters
tweetIdstring
Returns
GetUserByIdAsync(string)
ID を指定してユーザーを取得します。
public Task<GuestUser> GetUserByIdAsync(string userId)
Parameters
userIdstring
Returns
GetUserByScreenNameAsync(string)
スクリーンネームを指定してユーザーを取得します。
public Task<GuestUser> GetUserByScreenNameAsync(string screenName)
Parameters
screenNamestring
Returns
GetUserHighlightsTweetsAsync(string, int, string?)
ユーザーのハイライトツイートを取得します。
public Task<Result<GuestTweet>> GetUserHighlightsTweetsAsync(string userId, int count = 20, string? cursor = null)
Parameters
Returns
GetUserTweetsAsync(string, string, int)
ユーザーのツイートを取得します。
public Task<List<GuestTweet>> GetUserTweetsAsync(string userId, string tweetType = "Tweets", int count = 40)
Parameters
Returns
PostAsync(string, RequestOptions?)
public Task<ApiResponse> PostAsync(string url, RequestOptions? options = null)
Parameters
urlstringoptionsRequestOptions
Returns
RequestAsync(HttpMethod, string, RequestOptions?)
public Task<ApiResponse> RequestAsync(HttpMethod method, string url, RequestOptions? options = null)
Parameters
methodHttpMethodurlstringoptionsRequestOptions
Returns
SendAsync(HttpMethod, string, RequestOptions?)
生のリクエスト(Python 版の _send)。メディアのダウンロードなどが使います。
public Task<HttpResponseMessage> SendAsync(HttpMethod method, string url, RequestOptions? options = null)
Parameters
methodHttpMethodurlstringoptionsRequestOptions