Documentation
¶
Overview ¶
Package twittertimeline provides a client for accessing Twitter/X API without authorization
Index ¶
Constants ¶
const ( BearerToken = "AAAAAAAAAAAAAAAAAAAAAFQODgEAAAAAVHTp76lzh3rFzcHbmHVvQxYYpTw%3DckAlMINMjmCwxUcaXbAN4XqJVdgMJaHqNOFgPMK0zN1qLqLQCF" BaseURL = "https://api.x.com" UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36" // GraphQL API endpoints UserByScreenNamePath = "/graphql/x3RLKWW1Tl7JgU7YtGxuzw/UserByScreenName" UserTweetsPath = "/graphql/bbmwRjH_roUoWsvbgAJY9g/UserTweets" )
Constants for Twitter API
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a client for working with Twitter API
func (*Client) GetGuestToken ¶
GetGuestToken gets guest token from Twitter API
func (*Client) GetUserByScreenName ¶
func (c *Client) GetUserByScreenName(screenName string) (*UserResponse, error)
GetUserByScreenName gets user information by screen_name (username)
func (*Client) GetUserID ¶
GetUserID gets user ID by username with caching for frequently requested users
func (*Client) GetUserTweets ¶
GetUserTweets gets user timeline by user ID and returns a list of tweets
func (*Client) SetProxy ¶
SetProxy sets HTTP/HTTPS proxy for the client Example: client.SetProxy("http://proxy.example.com:8080") Example: client.SetProxy("https://user:pass@proxy.example.com:8080") To remove proxy: client.SetProxy("")
type GuestTokenResponse ¶
type GuestTokenResponse struct {
GuestToken string `json:"guest_token"`
}
Structures for parsing JSON responses
type MediaEntity ¶
type TimelineEntry ¶
type TimelineEntry struct { EntryID string `json:"entryId"` Content struct { EntryType string `json:"entryType"` ItemContent *struct { TweetResults struct { Result TweetResult `json:"result"` } `json:"tweet_results"` } `json:"itemContent"` Items *[]struct { EntryID string `json:"entryId"` Item struct { ItemContent struct { TweetResults struct { Result TweetResult `json:"result"` } `json:"tweet_results"` } `json:"itemContent"` } `json:"item"` } `json:"items"` } `json:"content"` }
type TimelineResponse ¶
type TimelineResponse struct { Data struct { User struct { Result struct { Timeline struct { Timeline struct { Instructions []struct { Type string `json:"type"` Entries []TimelineEntry `json:"entries"` Entry *TimelineEntry `json:"entry"` } `json:"instructions"` } `json:"timeline"` } `json:"timeline"` } `json:"result"` } `json:"user"` } `json:"data"` }
type Tweet ¶
type Tweet struct { // Basic information ID string // RestID Text string // FullText HTML string // HTML version with links CreatedAt string // Creation date PermanentURL string // Permanent link to tweet // Author Username string // Username (@username) UserID string // User ID // Statistics (top level) Likes int // FavoriteCount Retweets int // RetweetCount Replies int // ReplyCount // Tweet types (boolean flags as is) IsPinned bool // Whether tweet is pinned IsRetweet bool // Retweet IsQuoted bool // Quote IsReply bool // Reply // Media and links Images []string // Image URLs URLs []URL // Links Mentions []string // User mentions (username only) }
Public API structures
type TweetResult ¶
type TweetResult struct { RestID string `json:"rest_id"` Core struct { UserResults struct { Result struct { Core struct { ScreenName string `json:"screen_name"` } `json:"core"` } `json:"result"` } `json:"user_results"` } `json:"core"` Legacy struct { FullText string `json:"full_text"` CreatedAt string `json:"created_at"` UserIDStr string `json:"user_id_str"` InReplyToStatusIDStr string `json:"in_reply_to_status_id_str"` InReplyToUserIDStr string `json:"in_reply_to_user_id_str"` InReplyToScreenName string `json:"in_reply_to_screen_name"` IsQuoteStatus bool `json:"is_quote_status"` QuotedStatusIDStr string `json:"quoted_status_id_str"` RetweetedStatusIDStr string `json:"retweeted_status_id_str"` Entities struct { Hashtags []struct { Text string `json:"text"` } `json:"hashtags"` Urls []struct { URL string `json:"url"` ExpandedURL string `json:"expanded_url"` DisplayURL string `json:"display_url"` } `json:"urls"` Media []MediaEntity `json:"media"` } `json:"entities"` ExtendedEntities struct { Media []MediaEntity `json:"media"` } `json:"extended_entities"` FavoriteCount int `json:"favorite_count"` RetweetCount int `json:"retweet_count"` ReplyCount int `json:"reply_count"` } `json:"legacy"` RetweetedStatusResult struct { Result *TweetResult `json:"result"` } `json:"retweeted_status_result"` IsPinned bool `json:"-"` // Not from JSON, set by code IsRetweet bool `json:"-"` // Not from JSON, determined by code IsQuoted bool `json:"-"` // Not from JSON, determined by code IsReply bool `json:"-"` // Not from JSON, determined by code Images []string `json:"-"` // Not from JSON, extracted from media URL string `json:"-"` // Not from JSON, permanent URL to tweet HTML string `json:"-"` // Not from JSON, HTML formatted content }
type UserResponse ¶
type UserResponse struct { Data struct { User struct { Result struct { RestID string `json:"rest_id"` ID string `json:"id"` Legacy struct { UserInfo `json:"legacy"` } `json:"legacy"` Core struct { Name string `json:"name"` ScreenName string `json:"screen_name"` } `json:"core"` } `json:"result"` } `json:"user"` } `json:"data"` Errors []struct { Message string `json:"message"` Code int `json:"code"` } `json:"errors"` }