Documentation
¶
Index ¶
- func IntPtr(i int) *int
- func StringPtr(s string) *string
- type Client
- func (c *Client) ExecuteGraphQL(variables map[string]interface{}, queryID string, operationName string, ...) (map[string]interface{}, error)
- func (c *Client) GetCSRFToken() string
- func (c *Client) OnCSRFRefreshed(fn func(newToken string))
- func (c *Client) SetCSRFToken(token string)
- func (c *Client) SetCookies(cookies string)
- func (c *Client) SetHTTPClient(httpClient *http.Client)
- func (c *Client) SetTransactionIDGenerator(key string, frames [][][]int)
- func (c *Client) UploadMedia(filePath string, mediaType string) (string, error)
- func (c *Client) UploadMediaBytes(data []byte, mediaType string) (string, error)
- type CreateTweetOptions
- type GraphQLRequest
- type ImageInfo
- type MediaEntity
- type MediaUploadResponse
- type PublicMetrics
- type ScheduledTweet
- type TransactionIDGenerator
- type Tweet
- type TweetLegacy
- type TweetsService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
Tweets *TweetsService
// contains filtered or unexported fields
}
Client represents a Twitter API client authenticated with a token.
func (*Client) ExecuteGraphQL ¶
func (c *Client) ExecuteGraphQL( variables map[string]interface{}, queryID string, operationName string, features map[string]bool, ) (map[string]interface{}, error)
ExecuteGraphQL executes a GraphQL query with variables, queryID, operation name, and features
func (*Client) GetCSRFToken ¶
GetCSRFToken returns the current CSRF token (ct0 cookie value)
func (*Client) OnCSRFRefreshed ¶
OnCSRFRefreshed registers a callback invoked whenever the ct0 token is refreshed from a response. Useful for persisting the updated token to a cache or storage.
func (*Client) SetCSRFToken ¶
SetCSRFToken sets the CSRF token for requests
func (*Client) SetCookies ¶
SetCookies sets the cookies for requests
func (*Client) SetHTTPClient ¶
SetHTTPClient allows you to provide a custom HTTP client.
func (*Client) SetTransactionIDGenerator ¶
SetTransactionIDGenerator sets the transaction ID generator with frames and key
func (*Client) UploadMedia ¶
UploadMedia uploads a media file from a file path and returns the media ID
type CreateTweetOptions ¶
type CreateTweetOptions struct {
MediaIDs []string `json:"media_ids,omitempty"`
MediaEntities []MediaEntity `json:"media_entities,omitempty"`
ReplyTo *string `json:"reply_to,omitempty"`
Sensitive bool `json:"sensitive,omitempty"`
}
CreateTweetOptions contains options for creating a tweet.
type GraphQLRequest ¶
type GraphQLRequest struct {
Variables map[string]interface{} `json:"variables"`
QueryID string `json:"queryId"`
Features map[string]bool `json:"features"`
}
GraphQLRequest represents a GraphQL request with variables and features
type ImageInfo ¶
type ImageInfo struct {
ImageType string `json:"image_type"`
Width int `json:"w"`
Height int `json:"h"`
}
ImageInfo contains image metadata
type MediaEntity ¶
type MediaEntity struct {
MediaID string `json:"media_id"`
TaggedUsers []interface{} `json:"tagged_users"`
}
MediaEntity represents a media attachment in a tweet
type MediaUploadResponse ¶
type MediaUploadResponse struct {
MediaID int64 `json:"media_id"`
MediaIDString string `json:"media_id_string"`
MediaKey string `json:"media_key"`
ExpiresAfter int `json:"expires_after_secs"`
Size int `json:"size,omitempty"`
Image *ImageInfo `json:"image,omitempty"`
}
MediaUploadResponse represents the response from media upload operations
type PublicMetrics ¶
type PublicMetrics struct {
RetweetCount int `json:"retweet_count"`
ReplyCount int `json:"reply_count"`
LikeCount int `json:"like_count"`
BookmarkCount int `json:"bookmark_count"`
}
PublicMetrics contains tweet metrics
type ScheduledTweet ¶
type ScheduledTweet struct {
ID string `json:"id"`
Text string `json:"text"`
ScheduledAt time.Time `json:"scheduled_at"`
}
ScheduledTweet represents a scheduled tweet.
type TransactionIDGenerator ¶
type TransactionIDGenerator struct {
// contains filtered or unexported fields
}
TransactionIDGenerator generates X-Client-Transaction-ID headers
func NewTransactionIDGenerator ¶
func NewTransactionIDGenerator(frames [][][]int) *TransactionIDGenerator
NewTransactionIDGenerator creates a new generator with frame data
func (*TransactionIDGenerator) GenerateHeader ¶
func (g *TransactionIDGenerator) GenerateHeader(path, method, key string) string
GenerateHeader generates an X-Client-Transaction-ID header
type Tweet ¶
type Tweet struct {
ID string `json:"rest_id"`
Legacy *TweetLegacy `json:"legacy"`
}
Tweet represents a Twitter tweet.
type TweetLegacy ¶
type TweetLegacy struct {
FullText string `json:"full_text"`
CreatedAt string `json:"created_at"`
PublicMetrics *PublicMetrics `json:"public_metrics"`
}
TweetLegacy contains the legacy tweet data
type TweetsService ¶
type TweetsService struct {
// contains filtered or unexported fields
}
TweetsService handles tweet-related API operations.
func (*TweetsService) Create ¶
func (s *TweetsService) Create(text string, opts *CreateTweetOptions) (*Tweet, error)
Create creates a new tweet.
func (*TweetsService) Delete ¶
func (s *TweetsService) Delete(tweetID string) error
Delete deletes a tweet by ID.