Documentation ¶
Index ¶
- Variables
- type Attachment
- type Counts
- type Deleted
- type Entities
- type Expansion
- type Geo
- type GetTweetOption
- type GetTweetsCountsOption
- type GetTweetsSearchOption
- type GetUserFollowOption
- type GetUserTweetOption
- type Granularity
- type MediaField
- type OAuth2
- type OrganicMetrics
- type PlaceField
- type PollField
- type PostTweetGeoParams
- type PostTweetMediaParams
- type PostTweetParams
- type PostTweetPollParams
- type PostTweetReplyParams
- type PromotedMetrics
- type PublicMetrics
- type ReferencedTweet
- type Response
- type ResponseError
- type Scope
- type SortOrder
- type Token
- type Tweet
- type TweetField
- type Twitter
- func (t *Twitter) DeleteTweet(id int64) (*Response[*Deleted], error)
- func (t *Twitter) GetTweet(id int64, opts ...GetTweetOption) (*Response[*Tweet], error)
- func (t *Twitter) GetTweets(ids []int64, opts ...GetTweetOption) (*Response[[]*Tweet], error)
- func (t *Twitter) GetTweetsCountsAll(query string, opts ...GetTweetsCountsOption) (*Response[[]*Counts], error)
- func (t *Twitter) GetTweetsCountsRecent(query string, opts ...GetTweetsCountsOption) (*Response[[]*Counts], error)
- func (t *Twitter) GetTweetsSearchAll(query string, opts ...GetTweetsSearchOption) (*Response[[]*Tweet], error)
- func (t *Twitter) GetTweetsSearchRecent(query string, opts ...GetTweetsSearchOption) (*Response[[]*Tweet], error)
- func (t *Twitter) GetUserFollowers(id int64, opts ...GetUserFollowOption) (*Response[[]*User], error)
- func (t *Twitter) GetUserFollowing(id int64, opts ...GetUserFollowOption) (*Response[[]*User], error)
- func (t *Twitter) GetUserMentions(id int64, opts ...GetUserTweetOption) (*Response[[]*Tweet], error)
- func (t *Twitter) GetUserTweets(id int64, opt ...GetUserTweetOption) (*Response[[]*Tweet], error)
- func (t *Twitter) PostTweet(params *PostTweetParams) (*Response[*Tweet], error)
- type User
- type UserField
- type WithEndTime
- type WithExpansions
- type WithGranularity
- type WithMaxResults
- type WithMediaFields
- type WithNextToken
- type WithPaginationToken
- type WithPlaceFields
- type WithPollFields
- type WithSinceID
- type WithSortOrder
- type WithStartTime
- type WithTweetFields
- type WithUntilID
- type WithUserFields
- type Withheld
Constants ¶
This section is empty.
Variables ¶
var ExpansionsAll = []Expansion{ ExpansionAttachmentsPollIDs, ExpansionAttachmentsMediaKeys, ExpansionAuthorID, ExpansionEntitiesMentionsUsername, ExpansionGeoPlaceID, ExpansionInReplyToUserID, ExpansionReferencedTweetsID, ExpansionReferencedTweetsIDAuthorID, }
var MediaFieldsAll = []MediaField{ MediaFieldDurationMS, MediaFieldHeight, MediaFieldMediaKey, MediaFieldPreviewImageURL, MediaFieldType, MediaFieldURL, MediaFieldWidth, MediaFieldPublicMetrics, MediaFieldNonPublicMetrics, MediaFieldOrganicMetrics, MediaFieldPromotedMetrics, MediaFieldAltText, }
var PlaceFieldsAll = []PlaceField{ PlaceFieldContainedWithin, PlaceFieldCountry, PlaceFieldFullName, PlaceFieldGeo, PlaceFieldID, PlaceFieldName, PlaceFieldPlaceType, }
var PollFieldsAll = []PollField{ PollFieldDurationMinutes, PollFieldEndDatetime, PollFieldID, PollFieldOptions, PollFieldVotingStatus, }
var TweetFieldsAll = []TweetField{ TweetFieldAttachments, TweetFieldAuthorID, TweetFieldContextAnnotations, TweetFieldConversationID, TweetFieldCreatedAt, TweetFieldEntities, TweetFieldGeo, TweetFieldID, TweetFieldInReplyToUserID, TweetFieldLang, TweetFieldNonPublicMetrics, TweetFieldPublicMetrics, TweetFieldOrganicMetrics, TweetFieldPromotedMetrics, TweetFieldPossiblySensitive, TweetFieldReferencedTweets, TweetFieldReplySettings, TweetFieldSource, TweetFieldText, TweetFieldWithheld, }
var UserFieldsAll = []UserField{ UserFieldCreatedAt, UserFieldDescription, UserFieldEntities, UserFieldID, UserFieldLocation, UserFieldPinnedTweetID, UserFieldProfileImageURL, UserFieldProtected, UserFieldPublicMetrics, UserFieldURL, UserFieldUsername, UserFieldVerified, UserFieldWithheld, }
Functions ¶
This section is empty.
Types ¶
type Expansion ¶
type Expansion string
const ( ExpansionAttachmentsPollIDs Expansion = "attachments.poll_ids" ExpansionAttachmentsMediaKeys Expansion = "attachments.media_keys" ExpansionAuthorID Expansion = "author_id" ExpansionEntitiesMentionsUsername Expansion = "entities.mentions.username" ExpansionGeoPlaceID Expansion = "geo.place_id" ExpansionInReplyToUserID Expansion = "in_reply_to_user_id" ExpansionReferencedTweetsID Expansion = "referenced_tweets.id" ExpansionReferencedTweetsIDAuthorID Expansion = "referenced_tweets.id.author_id" )
type GetTweetOption ¶
type GetTweetOption interface {
// contains filtered or unexported methods
}
type GetTweetsCountsOption ¶
type GetTweetsCountsOption interface {
// contains filtered or unexported methods
}
type GetTweetsSearchOption ¶
type GetTweetsSearchOption interface {
// contains filtered or unexported methods
}
type GetUserFollowOption ¶
type GetUserFollowOption interface {
// contains filtered or unexported methods
}
type GetUserTweetOption ¶
type GetUserTweetOption interface {
// contains filtered or unexported methods
}
type Granularity ¶
type Granularity string
const ( GranularityMinute Granularity = "minute" GranularityHour Granularity = "hour" GranularityDay Granularity = "day" )
type MediaField ¶
type MediaField string
const ( MediaFieldDurationMS MediaField = "duration_ms" MediaFieldHeight MediaField = "height" MediaFieldMediaKey MediaField = "media_key" MediaFieldPreviewImageURL MediaField = "preview_image_url" MediaFieldType MediaField = "type" MediaFieldURL MediaField = "url" MediaFieldWidth MediaField = "width" MediaFieldPublicMetrics MediaField = "public_metrics" MediaFieldNonPublicMetrics MediaField = "non_public_metrics" MediaFieldOrganicMetrics MediaField = "organic_metrics" MediaFieldPromotedMetrics MediaField = "promoted_metrics" MediaFieldAltText MediaField = "alt_text" )
type OAuth2 ¶
type OAuth2 struct { ClientID string ClientSecret string RedirectURI string Client *http.Client // contains filtered or unexported fields }
func (*OAuth2) AuthCodeURL ¶
type PlaceField ¶
type PlaceField string
const ( PlaceFieldContainedWithin PlaceField = "contained_within" PlaceFieldCountry PlaceField = "country" PlaceFieldFullName PlaceField = "full_name" PlaceFieldGeo PlaceField = "geo" PlaceFieldID PlaceField = "id" PlaceFieldName PlaceField = "name" PlaceFieldPlaceType PlaceField = "place_type" )
type PostTweetGeoParams ¶
type PostTweetGeoParams struct {
PlaceID string `json:"place_id,omitempty"`
}
type PostTweetMediaParams ¶
type PostTweetParams ¶
type PostTweetParams struct { DirectMessageDeepLink string `json:"direct_message_deeplink,omitempty"` ForSuperFollowersOnly bool `json:"for_super_followers_only,omitempty"` Geo *PostTweetGeoParams `json:"geo,omitempty"` Media *PostTweetMediaParams `json:"media,omitempty"` Poll *PostTweetPollParams `json:"poll,omitempty"` QuoteTweetID int64 `json:"quote_tweet_id,string,omitempty"` Reply *PostTweetReplyParams `json:"reply,omitempty"` ReplySettings string `json:"reply_settings,omitempty"` Text string `json:"text,omitempty"` }
type PostTweetPollParams ¶
type PostTweetReplyParams ¶
type ReferencedTweet ¶
type Response ¶
type Response[T any] struct { Data T `json:"data"` Includes *struct { Users []*User `json:"users,omitempty"` } `json:"includes,omitempty"` Meta *struct { ResultCount int `json:"result_count"` NextToken string `json:"next_token"` NewestID int64 `json:"newest_id,string"` OldestID int64 `json:"oldest_id,string"` TotalTweetCount int `json:"total_tweet_count"` } `json:"meta,omitempty"` }
func (*Response[T]) IncludeUser ¶
type ResponseError ¶
type ResponseError struct { Errors []struct { Parameters struct { Expansions []string `json:"expansions"` } `json:"parameters"` Message string `json:"message"` } `json:"errors"` Title string `json:"title"` Detail string `json:"detail"` Type string `json:"type"` }
func (*ResponseError) Error ¶
func (e *ResponseError) Error() string
type Scope ¶
type Scope string
Scope
https://developer.twitter.com/en/docs/authentication/oauth-2-0/authorization-code#scopes
const ( // All the Tweets you can view, including Tweets from protected accounts. ScopeTweetRead Scope = "tweet.read" // Tweet and Retweet for you. ScopeTweetWrite Scope = "tweet.write" // Hide and unhide replies to your Tweets. ScopeTweetModerateWrite Scope = "tweet.moderate.write" // Any account you can view, including protected accounts. ScopeUsersRead Scope = "users.read" // People who follow you and people who you follow. ScopeFollowsRead Scope = "follows.read" // Follow and unfollow people for you. ScopeFollowsWrite Scope = "follows.write" // Stay connected to your account until you revoke access. ScopeOfflineAccess Scope = "offline.access" // All the Spaces you can view. ScopeSpaceRead Scope = "space.read" // Accounts you’ve muted. ScopeMuteRead Scope = "mute.read" // Mute and unmute accounts for you. ScopeMuteWrite Scope = "mute.write" // Tweets you’ve liked and likes you can view. ScopeLikeRead Scope = "like.read" // Like and un-like Tweets for you. ScopeLikeWrite Scope = "like.write" // Lists, list members, and list followers of lists you’ve created or are a member of, including private lists. ScopeListRead Scope = "list.read" // Create and manage Lists for you. ScopeListWrite Scope = "list.write" // Accounts you’ve blocked. ScopeBlockRead Scope = "block.read" // Block and unblock accounts for you. ScopeBlockWrite Scope = "block.write" // Get Bookmarked Tweets from an authenticated user. ScopeBookmarkRead Scope = "bookmark.read" // Bookmark and remove Bookmarks from Tweets ScopeBookmarkWrite Scope = "bookmark.write" )
var ( ScopeTweet Scope = fmtScope(ScopeTweetRead, ScopeTweetWrite, ScopeTweetModerateWrite) ScopeMute Scope = fmtScope(ScopeMuteRead, ScopeMuteWrite) ScopeLike Scope = fmtScope(ScopeLikeRead, ScopeLikeWrite) ScopeBlock Scope = fmtScope(ScopeBlockRead, ScopeBlockWrite) ScopeBookmark Scope = fmtScope(ScopeBookmarkRead, ScopeBookmarkWrite) ScopeFollowes Scope = fmtScope(ScopeFollowsRead, ScopeFollowsWrite) ScopeAll Scope = fmtScope(ScopeTweet, ScopeUsersRead, ScopeFollowes, ScopeOfflineAccess, ScopeSpaceRead, ScopeMute, ScopeLike, ScopeBlock, ScopeBookmark, ) )
type Tweet ¶
type Tweet struct { ID int64 `json:"id,string"` Text string `json:"text"` Attachment *Attachment `json:"attachment,omitempty"` AuthorID int64 `json:"author_id,string"` ContextAnnotations []any `json:"context_annotations,omitempty"` ConversationID int64 `json:"conversation_id,string"` CreatedAt time.Time `json:"created_at"` Entities *Entities `json:"entities,omitempty"` Geo *Geo `json:"geo,omitempty"` InReplyToUserID int64 `json:"in_reply_to_user_id,string"` Lang string `json:"lang,omitempty"` OrganicMetrics *OrganicMetrics `json:"organic_metrics,omitempty"` PositiveSensitive bool `json:"positive_sensitive"` PromotedMetrics *PromotedMetrics `json:"promoted_metrics,omitempty"` ReferencedTweet []*ReferencedTweet `json:"referenced_tweet,omitempty"` ReplySettings string `json:"reply_settings"` Source string `json:"source"` Withheld *Withheld `json:"withheld,omitempty"` }
type TweetField ¶
type TweetField string
const ( TweetFieldAttachments TweetField = "attachments" TweetFieldAuthorID TweetField = "author_id" TweetFieldContextAnnotations TweetField = "context_annotations" TweetFieldConversationID TweetField = "conversation_id" TweetFieldCreatedAt TweetField = "created_at" TweetFieldEntities TweetField = "entities" TweetFieldGeo TweetField = "geo" TweetFieldID TweetField = "id" TweetFieldInReplyToUserID TweetField = "in_reply_to_user_id" TweetFieldLang TweetField = "lang" TweetFieldNonPublicMetrics TweetField = "non_public_metrics" TweetFieldPublicMetrics TweetField = "public_metrics" TweetFieldOrganicMetrics TweetField = "organic_metrics" TweetFieldPromotedMetrics TweetField = "promoted_metrics" TweetFieldPossiblySensitive TweetField = "possibly_sensitive" TweetFieldReferencedTweets TweetField = "referenced_tweets" TweetFieldReplySettings TweetField = "reply_settings" TweetFieldSource TweetField = "source" TweetFieldText TweetField = "text" TweetFieldWithheld TweetField = "withheld" )
type Twitter ¶
func (*Twitter) DeleteTweet ¶
DeleteTweet allows a user or authenticated user ID to delete a Tweet.
func (*Twitter) GetTweet ¶
GetTweet returns a variety of information about a single Tweet specified by the requested ID.
https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets-id
func (*Twitter) GetTweets ¶
GetTweets returns a variety of information about the Tweet specified by the requested ID or list of IDs.
https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets
func (*Twitter) GetTweetsCountsAll ¶
func (t *Twitter) GetTweetsCountsAll(query string, opts ...GetTweetsCountsOption) (*Response[[]*Counts], error)
This endpoint is only available to those users who have been approved for Academic Research access.
The full-archive Tweet counts endpoint returns the count of Tweets that match your query from the complete history of public Tweets; since the first Tweet was created March 26, 2006.
https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-all
func (*Twitter) GetTweetsCountsRecent ¶
func (t *Twitter) GetTweetsCountsRecent(query string, opts ...GetTweetsCountsOption) (*Response[[]*Counts], error)
GetTweetsCountsRecent returns count of Tweets from the last seven days that match a query.
func (*Twitter) GetTweetsSearchAll ¶
func (t *Twitter) GetTweetsSearchAll(query string, opts ...GetTweetsSearchOption) (*Response[[]*Tweet], error)
This endpoint is only available to those users who have been approved for Academic Research access.
The full-archive search endpoint returns the complete history of public Tweets matching a search query; since the first Tweet was created March 26, 2006.
The Tweets returned by this endpoint count towards the Project-level Tweet cap.
https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-all
func (*Twitter) GetTweetsSearchRecent ¶
func (t *Twitter) GetTweetsSearchRecent(query string, opts ...GetTweetsSearchOption) (*Response[[]*Tweet], error)
The recent search endpoint returns Tweets from the last seven days that match a search query.
The Tweets returned by this endpoint count towards the Project-level Tweet cap.
func (*Twitter) GetUserFollowers ¶
func (t *Twitter) GetUserFollowers(id int64, opts ...GetUserFollowOption) (*Response[[]*User], error)
GetUserFollowers returns a list of users who are followers of the specified user ID.
https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-followers
func (*Twitter) GetUserFollowing ¶
func (t *Twitter) GetUserFollowing(id int64, opts ...GetUserFollowOption) (*Response[[]*User], error)
GetUserFollow returns a list of users the specified user ID is following.
https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-following
func (*Twitter) GetUserMentions ¶
func (t *Twitter) GetUserMentions(id int64, opts ...GetUserTweetOption) (*Response[[]*Tweet], error)
GetUserMentions returns Tweets mentioning a single user specified by the requested user ID. By default, the most recent ten Tweets are returned per request. Using pagination, up to the most recent 800 Tweets can be retrieved.
The Tweets returned by this endpoint count towards the Project-level Tweet cap.
func (*Twitter) GetUserTweets ¶
GetUserTweets returns Tweets composed by a single user, specified by the requested user ID. By default, the most recent ten Tweets are returned per request. Using pagination, the most recent 3,200 Tweets can be retrieved.
The Tweets returned by this endpoint count towards the Project-level Tweet cap.
https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/api-reference/get-users-id-tweets
func (*Twitter) PostTweet ¶
func (t *Twitter) PostTweet(params *PostTweetParams) (*Response[*Tweet], error)
PostTweet creates a Tweet on behalf of an authenticated user.
https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets
type UserField ¶
type UserField string
const ( UserFieldCreatedAt UserField = "created_at" UserFieldDescription UserField = "description" UserFieldEntities UserField = "entities" UserFieldID UserField = "id" UserFieldLocation UserField = "location" UserFieldPinnedTweetID UserField = "pinned_tweet_id" UserFieldProfileImageURL UserField = "profile_image_url" UserFieldProtected UserField = "protected" UserFieldPublicMetrics UserField = "public_metrics" UserFieldURL UserField = "url" UserFieldUsername UserField = "username" UserFieldVerified UserField = "verified" UserFieldWithheld UserField = "withheld" )
type WithEndTime ¶
type WithExpansions ¶
type WithExpansions []Expansion
type WithGranularity ¶
type WithGranularity Granularity
type WithMaxResults ¶
type WithMaxResults int
type WithMediaFields ¶
type WithMediaFields []MediaField
type WithNextToken ¶
type WithNextToken string
type WithPaginationToken ¶
type WithPaginationToken string
type WithPlaceFields ¶
type WithPlaceFields []PlaceField
type WithPollFields ¶
type WithPollFields []PollField
type WithSinceID ¶
type WithSinceID int64
type WithSortOrder ¶
type WithSortOrder SortOrder
type WithStartTime ¶
type WithTweetFields ¶
type WithTweetFields []TweetField
type WithUntilID ¶
type WithUntilID int64
type WithUserFields ¶
type WithUserFields []UserField
Source Files ¶
- error.go
- oauth2.go
- resource_tweet_count.go
- resource_tweet_lookup.go
- resource_tweet_manage.go
- resource_tweet_search.go
- resource_tweet_timeline.go
- resource_user_follow.go
- response.go
- response_attachment.go
- response_count.go
- response_delete.go
- response_entity.go
- response_geo.go
- response_organic_metrics.go
- response_promoted_metrics.go
- response_public_metrics.go
- response_referenced_tweet.go
- response_tweet.go
- response_user.go
- response_withheld.go
- scope.go
- twitter.go
- util.go
- with.go
- with_expansion.go
- with_granularity.go
- with_media_field.go
- with_place_field.go
- with_poll_field.go
- with_sort_order.go
- with_tweet_field.go
- with_user_field.go