twitterv2

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool returns a new pointer to the given bool value.

func Float

func Float(v float64) *float64

Float returns a new pointer to the given float64 value.

Types

type APIError

type APIError struct {
	Errors []ErrorDetail `json:"errors"`
}

APIError represents a Twitter API Error response https://dev.twitter.com/overview/api/response-codes

func (APIError) Empty

func (e APIError) Empty() bool

Empty returns true if empty. Otherwise, at least 1 error message/code is present and false is returned.

func (APIError) Error

func (e APIError) Error() string

type BoundingBox

type BoundingBox struct {
	Coordinates [][][2]float64 `json:"coordinates"`
	Type        string         `json:"type"`
}

BoundingBox represents the bounding coordinates (longitude, latitutde) defining the bounds of a box containing a Place entity.

type Client

type Client struct {

	// Twitter API Services
	Users *UserService
	// contains filtered or unexported fields
}

Client is a Twitter client for making Twitter API requests.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Client.

type Coordinates

type Coordinates struct {
	Coordinates [2]float64 `json:"coordinates"`
	Type        string     `json:"type"`
}

Coordinates are pairs of longitude and latitude locations.

type Entities

type Entities struct {
	Hashtags     []HashtagEntity `json:"hashtags"`
	Media        []MediaEntity   `json:"media"`
	Urls         []URLEntity     `json:"urls"`
	UserMentions []MentionEntity `json:"user_mentions"`
}

Entities represent metadata and context info parsed from Twitter components. https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/entities-object TODO: symbols

type ErrorDetail

type ErrorDetail struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

ErrorDetail represents an individual item in an APIError.

type ExtendedEntity

type ExtendedEntity struct {
	Media []MediaEntity `json:"media"`
}

ExtendedEntity contains media information. https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/extended-entities-object

type ExtendedTweet

type ExtendedTweet struct {
	FullText         string          `json:"full_text"`
	DisplayTextRange Indices         `json:"display_text_range"`
	Entities         *Entities       `json:"entities"`
	ExtendedEntities *ExtendedEntity `json:"extended_entities"`
}

ExtendedTweet represents fields embedded in extended Tweets when served in compatibility mode (default). https://dev.twitter.com/overview/api/upcoming-changes-to-tweets

type HashtagEntity

type HashtagEntity struct {
	Indices Indices `json:"indices"`
	Text    string  `json:"text"`
}

HashtagEntity represents a hashtag which has been parsed from text.

type Indices

type Indices [2]int

Indices represent the start and end offsets within text.

func (Indices) End

func (i Indices) End() int

End returns the index at which an entity ends, exclusive.

func (Indices) Start

func (i Indices) Start() int

Start returns the index at which an entity starts, inclusive.

type MediaEntity

type MediaEntity struct {
	URLEntity
	ID                int64      `json:"id"`
	IDStr             string     `json:"id_str"`
	MediaURL          string     `json:"media_url"`
	MediaURLHttps     string     `json:"media_url_https"`
	SourceStatusID    int64      `json:"source_status_id"`
	SourceStatusIDStr string     `json:"source_status_id_str"`
	Type              string     `json:"type"`
	Sizes             MediaSizes `json:"sizes"`
	VideoInfo         VideoInfo  `json:"video_info"`
}

MediaEntity represents media elements associated with a Tweet.

type MediaSize

type MediaSize struct {
	Width  int    `json:"w"`
	Height int    `json:"h"`
	Resize string `json:"resize"`
}

MediaSize describes the height, width, and resizing method used.

type MediaSizes

type MediaSizes struct {
	Thumb  MediaSize `json:"thumb"`
	Large  MediaSize `json:"large"`
	Medium MediaSize `json:"medium"`
	Small  MediaSize `json:"small"`
}

MediaSizes contain the different size media that are available. https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/entities-object#media-size

type MentionEntity

type MentionEntity struct {
	Indices    Indices `json:"indices"`
	ID         int64   `json:"id"`
	IDStr      string  `json:"id_str"`
	Name       string  `json:"name"`
	ScreenName string  `json:"screen_name"`
}

MentionEntity represents Twitter user mentions parsed from text.

type OEmbedTweet

type OEmbedTweet struct {
	URL          string `json:"url"`
	ProviderURL  string `json:"provider_url"`
	ProviderName string `json:"provider_name"`
	AuthorName   string `json:"author_name"`
	Version      string `json:"version"`
	AuthorURL    string `json:"author_url"`
	Type         string `json:"type"`
	HTML         string `json:"html"`
	Height       int64  `json:"height"`
	Width        int64  `json:"width"`
	CacheAge     string `json:"cache_age"`
}

OEmbedTweet represents a Tweet in oEmbed format.

type Place

type Place struct {
	Attributes  map[string]string `json:"attributes"`
	BoundingBox *BoundingBox      `json:"bounding_box"`
	Country     string            `json:"country"`
	CountryCode string            `json:"country_code"`
	FullName    string            `json:"full_name"`
	Geometry    *BoundingBox      `json:"geometry"`
	ID          string            `json:"id"`
	Name        string            `json:"name"`
	PlaceType   string            `json:"place_type"`
	Polylines   []string          `json:"polylines"`
	URL         string            `json:"url"`
}

Place represents a Twitter Place / Location https://dev.twitter.com/overview/api/places

type StatusDestroyParams

type StatusDestroyParams struct {
	ID        int64  `url:"id,omitempty"`
	TrimUser  *bool  `url:"trim_user,omitempty"`
	TweetMode string `url:"tweet_mode,omitempty"`
}

StatusDestroyParams are the parameters for StatusService.Destroy

type StatusLookupParams

type StatusLookupParams struct {
	ID              []int64 `url:"id,omitempty,comma"`
	TrimUser        *bool   `url:"trim_user,omitempty"`
	IncludeEntities *bool   `url:"include_entities,omitempty"`
	Map             *bool   `url:"map,omitempty"`
	TweetMode       string  `url:"tweet_mode,omitempty"`
}

StatusLookupParams are the parameters for StatusService.Lookup

type StatusOEmbedParams

type StatusOEmbedParams struct {
	ID         int64  `url:"id,omitempty"`
	URL        string `url:"url,omitempty"`
	Align      string `url:"align,omitempty"`
	MaxWidth   int64  `url:"maxwidth,omitempty"`
	HideMedia  *bool  `url:"hide_media,omitempty"`
	HideThread *bool  `url:"hide_media,omitempty"`
	OmitScript *bool  `url:"hide_media,omitempty"`
	WidgetType string `url:"widget_type,omitempty"`
	HideTweet  *bool  `url:"hide_tweet,omitempty"`
}

StatusOEmbedParams are the parameters for StatusService.OEmbed

type StatusRetweetParams

type StatusRetweetParams struct {
	ID        int64  `url:"id,omitempty"`
	TrimUser  *bool  `url:"trim_user,omitempty"`
	TweetMode string `url:"tweet_mode,omitempty"`
}

StatusRetweetParams are the parameters for StatusService.Retweet

type StatusRetweetsParams

type StatusRetweetsParams struct {
	ID        int64  `url:"id,omitempty"`
	Count     int    `url:"count,omitempty"`
	TrimUser  *bool  `url:"trim_user,omitempty"`
	TweetMode string `url:"tweet_mode,omitempty"`
}

StatusRetweetsParams are the parameters for StatusService.Retweets

type StatusService

type StatusService struct {
	// contains filtered or unexported fields
}

StatusService provides methods for accessing Twitter status API endpoints.

func (*StatusService) Destroy

func (s *StatusService) Destroy(id int64, params *StatusDestroyParams) (*Tweet, *http.Response, error)

Destroy deletes the Tweet with the given id and returns it if successful. Requires a user auth context. https://dev.twitter.com/rest/reference/post/statuses/destroy/%3Aid

func (*StatusService) Lookup

func (s *StatusService) Lookup(ids []int64, params *StatusLookupParams) ([]Tweet, *http.Response, error)

Lookup returns the requested Tweets as a slice. Combines ids from the required ids argument and from params.Id. https://dev.twitter.com/rest/reference/get/statuses/lookup

func (*StatusService) OEmbed

OEmbed returns the requested Tweet in oEmbed format. https://dev.twitter.com/rest/reference/get/statuses/oembed

func (*StatusService) Retweet

func (s *StatusService) Retweet(id int64, params *StatusRetweetParams) (*Tweet, *http.Response, error)

Retweet retweets the Tweet with the given id and returns the original Tweet with embedded retweet details. Requires a user auth context. https://dev.twitter.com/rest/reference/post/statuses/retweet/%3Aid

func (*StatusService) Retweets

func (s *StatusService) Retweets(id int64, params *StatusRetweetsParams) ([]Tweet, *http.Response, error)

Retweets returns the most recent retweets of the Tweet with the given id. https://dev.twitter.com/rest/reference/get/statuses/retweets/%3Aid

func (*StatusService) Show

func (s *StatusService) Show(id int64, params *StatusShowParams) (*Tweet, *http.Response, error)

Show returns the requested Tweet. https://dev.twitter.com/rest/reference/get/statuses/show/%3Aid

func (*StatusService) Unretweet

func (s *StatusService) Unretweet(id int64, params *StatusUnretweetParams) (*Tweet, *http.Response, error)

Unretweet unretweets the Tweet with the given id and returns the original Tweet. Requires a user auth context. https://dev.twitter.com/rest/reference/post/statuses/unretweet/%3Aid

func (*StatusService) Update

func (s *StatusService) Update(status string, params *StatusUpdateParams) (*Tweet, *http.Response, error)

Update updates the user's status, also known as Tweeting. Requires a user auth context. https://dev.twitter.com/rest/reference/post/statuses/update

type StatusShowParams

type StatusShowParams struct {
	ID               int64  `url:"id,omitempty"`
	TrimUser         *bool  `url:"trim_user,omitempty"`
	IncludeMyRetweet *bool  `url:"include_my_retweet,omitempty"`
	IncludeEntities  *bool  `url:"include_entities,omitempty"`
	TweetMode        string `url:"tweet_mode,omitempty"`
}

StatusShowParams are the parameters for StatusService.Show

type StatusUnretweetParams

type StatusUnretweetParams struct {
	ID        int64  `url:"id,omitempty"`
	TrimUser  *bool  `url:"trim_user,omitempty"`
	TweetMode string `url:"tweet_mode,omitempty"`
}

StatusUnretweetParams are the parameters for StatusService.Unretweet

type StatusUpdateParams

type StatusUpdateParams struct {
	Status             string   `url:"status,omitempty"`
	InReplyToStatusID  int64    `url:"in_reply_to_status_id,omitempty"`
	PossiblySensitive  *bool    `url:"possibly_sensitive,omitempty"`
	Lat                *float64 `url:"lat,omitempty"`
	Long               *float64 `url:"long,omitempty"`
	PlaceID            string   `url:"place_id,omitempty"`
	DisplayCoordinates *bool    `url:"display_coordinates,omitempty"`
	TrimUser           *bool    `url:"trim_user,omitempty"`
	MediaIds           []int64  `url:"media_ids,omitempty,comma"`
	TweetMode          string   `url:"tweet_mode,omitempty"`
}

StatusUpdateParams are the parameters for StatusService.Update

type Tweet

type Tweet struct {
	Coordinates          *Coordinates           `json:"coordinates"`
	CreatedAt            string                 `json:"created_at"`
	CurrentUserRetweet   *TweetIdentifier       `json:"current_user_retweet"`
	Entities             *Entities              `json:"entities"`
	FavoriteCount        int                    `json:"favorite_count"`
	Favorited            bool                   `json:"favorited"`
	FilterLevel          string                 `json:"filter_level"`
	ID                   int64                  `json:"id"`
	IDStr                string                 `json:"id_str"`
	InReplyToScreenName  string                 `json:"in_reply_to_screen_name"`
	InReplyToStatusID    int64                  `json:"in_reply_to_status_id"`
	InReplyToStatusIDStr string                 `json:"in_reply_to_status_id_str"`
	InReplyToUserID      int64                  `json:"in_reply_to_user_id"`
	InReplyToUserIDStr   string                 `json:"in_reply_to_user_id_str"`
	Lang                 string                 `json:"lang"`
	PossiblySensitive    bool                   `json:"possibly_sensitive"`
	QuoteCount           int                    `json:"quote_count"`
	ReplyCount           int                    `json:"reply_count"`
	RetweetCount         int                    `json:"retweet_count"`
	Retweeted            bool                   `json:"retweeted"`
	RetweetedStatus      *Tweet                 `json:"retweeted_status"`
	Source               string                 `json:"source"`
	Scopes               map[string]interface{} `json:"scopes"`
	Text                 string                 `json:"text"`
	FullText             string                 `json:"full_text"`
	DisplayTextRange     Indices                `json:"display_text_range"`
	Place                *Place                 `json:"place"`
	Truncated            bool                   `json:"truncated"`
	User                 *User                  `json:"user"`
	WithheldCopyright    bool                   `json:"withheld_copyright"`
	WithheldInCountries  []string               `json:"withheld_in_countries"`
	WithheldScope        string                 `json:"withheld_scope"`
	ExtendedEntities     *ExtendedEntity        `json:"extended_entities"`
	ExtendedTweet        *ExtendedTweet         `json:"extended_tweet"`
	QuotedStatusID       int64                  `json:"quoted_status_id"`
	QuotedStatusIDStr    string                 `json:"quoted_status_id_str"`
	QuotedStatus         *Tweet                 `json:"quoted_status"`
}

Tweet represents a Twitter Tweet, previously called a status. https://dev.twitter.com/overview/api/tweets

func (Tweet) CreatedAtTime

func (t Tweet) CreatedAtTime() (time.Time, error)

CreatedAtTime returns the time a tweet was created.

type TweetIdentifier

type TweetIdentifier struct {
	ID    int64  `json:"id"`
	IDStr string `json:"id_str"`
}

TweetIdentifier represents the id by which a Tweet can be identified.

type URLEntity

type URLEntity struct {
	Indices     Indices `json:"indices"`
	DisplayURL  string  `json:"display_url"`
	ExpandedURL string  `json:"expanded_url"`
	URL         string  `json:"url"`
}

URLEntity represents a URL which has been parsed from text.

type User

type User struct {
	ContributorsEnabled            bool          `json:"contributors_enabled"`
	CreatedAt                      string        `json:"created_at"`
	DefaultProfile                 bool          `json:"default_profile"`
	DefaultProfileImage            bool          `json:"default_profile_image"`
	Description                    string        `json:"description"`
	Email                          string        `json:"email"`
	Entities                       *UserEntities `json:"entities"`
	FavouritesCount                int           `json:"favourites_count"`
	FollowRequestSent              bool          `json:"follow_request_sent"`
	Following                      bool          `json:"following"`
	FollowersCount                 int           `json:"followers_count"`
	FriendsCount                   int           `json:"friends_count"`
	GeoEnabled                     bool          `json:"geo_enabled"`
	ID                             int64         `json:"id"`
	IDStr                          string        `json:"id_str"`
	IsTranslator                   bool          `json:"is_translator"`
	Lang                           string        `json:"lang"`
	ListedCount                    int           `json:"listed_count"`
	Location                       string        `json:"location"`
	Name                           string        `json:"name"`
	Notifications                  bool          `json:"notifications"`
	ProfileBackgroundColor         string        `json:"profile_background_color"`
	ProfileBackgroundImageURL      string        `json:"profile_background_image_url"`
	ProfileBackgroundImageURLHttps string        `json:"profile_background_image_url_https"`
	ProfileBackgroundTile          bool          `json:"profile_background_tile"`
	ProfileBannerURL               string        `json:"profile_banner_url"`
	ProfileImageURL                string        `json:"profile_image_url"`
	ProfileImageURLHttps           string        `json:"profile_image_url_https"`
	ProfileLinkColor               string        `json:"profile_link_color"`
	ProfileSidebarBorderColor      string        `json:"profile_sidebar_border_color"`
	ProfileSidebarFillColor        string        `json:"profile_sidebar_fill_color"`
	ProfileTextColor               string        `json:"profile_text_color"`
	ProfileUseBackgroundImage      bool          `json:"profile_use_background_image"`
	Protected                      bool          `json:"protected"`
	ScreenName                     string        `json:"screen_name"`
	ShowAllInlineMedia             bool          `json:"show_all_inline_media"`
	Status                         *Tweet        `json:"status"`
	StatusesCount                  int           `json:"statuses_count"`
	Timezone                       string        `json:"time_zone"`
	URL                            string        `json:"url"`
	UtcOffset                      int           `json:"utc_offset"`
	Verified                       bool          `json:"verified"`
	WithheldInCountries            []string      `json:"withheld_in_countries"`
	WithholdScope                  string        `json:"withheld_scope"`
}

User represents a Twitter User. https://dev.twitter.com/overview/api/users

type UserEntities

type UserEntities struct {
	URL         Entities `json:"url"`
	Description Entities `json:"description"`
}

UserEntities contain Entities parsed from User url and description fields. https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/entities-object#mentions

type UserMeParams

type UserMeParams struct {
}

UserMeParams are the parameters for UserService.Me.

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

UserService provides methods for accessing Twitter user API endpoints.

func (*UserService) Me

func (s *UserService) Me(params *UserMeParams) (*User, *http.Response, error)

Returns information about an authorized user. Requires a user auth context. https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-me

type VideoInfo

type VideoInfo struct {
	AspectRatio    [2]int         `json:"aspect_ratio"`
	DurationMillis int            `json:"duration_millis"`
	Variants       []VideoVariant `json:"variants"`
}

VideoInfo is available on video media objects.

type VideoVariant

type VideoVariant struct {
	ContentType string `json:"content_type"`
	Bitrate     int    `json:"bitrate"`
	URL         string `json:"url"`
}

VideoVariant describes one of the available video formats.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL