twitter

package
v0.0.0-...-d66f68d Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 6 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 Client

type Client struct {
	Tweets *TweetsService
	// contains filtered or unexported fields
}

Client is a Twitter client for making Twitter 2 API requests.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Client.

type ErrorDetail

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

ErrorDetail represents an individual item in an APIError.

type Tweet

type Tweet struct {
	ID               string                 `json:"id"`
	Attachments      *TweetAttachments      `json:"attachments"`
	AuthorID         string                 `json:"author_id"`
	CreatedAt        string                 `json:"created_at"`
	NonPublicMetrics *TweetNonPublicMetrics `json:"non_public_metrics"`
	OrganicMetrics   *TweetOrganicMetrics   `json:"organic_metrics"`
	PublicMetrics    *TweetPublicMetrics    `json:"public_metrics"`
	Text             string                 `json:"text"`
}

func (Tweet) AuthorIDInt64

func (t Tweet) AuthorIDInt64() (int64, error)

AuthorIDInt64 returns the AuthorID as int64

func (Tweet) CreatedAtTime

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

CreatedAtTime returns the time a tweet was created.

func (Tweet) IDInt64

func (t Tweet) IDInt64() (int64, error)

IDInt64 returns the ID as int64

type TweetAttachments

type TweetAttachments struct {
	MediaKeys []string `json:"media_keys"`
}

type TweetError

type TweetError struct {
	Detail       string `json:"detail"`
	ResourceID   string `json:"resource_id"`
	ResourceType string `json:"resource_type"`
	Title        string `json:"title"`
	Section      string `json:"section"`
	Type         string `json:"type"`
}

type TweetInclude

type TweetInclude struct {
	Media *[]TweetMedia `json:"media"`
}

type TweetMedia

type TweetMedia struct {
	DurationMS       int64                  `json:"duration_ms"`
	Height           int64                  `json:"height"`
	MediaKey         string                 `json:"media_key"`
	OrganicMetrics   *VideoOrganicMetrics   `json:"organic_metrics"`
	NonPublicMetrics *VideoNonPublicMetrics `json:"non_public_metrics"`
	PreviewImageURL  string                 `json:"preview_image_url"`
	PublicMetrics    *VideoPublicMetrics    `json:"public_metrics"`
	Type             string                 `json:"type"`
	URL              string                 `json:"url"`
	Width            int64                  `json:"width"`
}

type TweetNonPublicMetrics

type TweetNonPublicMetrics struct {
	UserProfileClicks int `json:"user_profile_clicks"`
	ImpressionCount   int `json:"impression_count"`
	URLLinkClicks     int `json:"url_link_clicks"`
}

type TweetOrganicMetrics

type TweetOrganicMetrics struct {
	ReplyCount        int `json:"reply_count"`
	LikeCount         int `json:"like_count"`
	RetweetCount      int `json:"retweet_count"`
	URLLinkClicks     int `json:"url_link_clicks"`
	UserProfileClicks int `json:"user_profile_clicks"`
	ImpressionCount   int `json:"impression_count"`
}

type TweetPublicMetrics

type TweetPublicMetrics struct {
	RetweetCount int `json:"retweet_count"`
	ReplyCount   int `json:"reply_count"`
	LikeCount    int `json:"like_count"`
	QuoteCount   int `json:"quote_count"`
}

type Tweets

type Tweets struct {
	Data     []Tweet       `json:"data"`
	Errors   []TweetError  `json:"errors"`
	Includes *TweetInclude `json:"includes"`
}

type TweetsService

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

TweetsService provides methods for accessing Twitter tweets API endpoints.

func (*TweetsService) Show

func (s *TweetsService) Show(params *TweetsShowParams) (Tweets, *http.Response, error)

Show returns the requested Tweet. https://developer.twitter.com/en/docs/twitter-api/tweets

type TweetsShowParams

type TweetsShowParams struct {
	IDs                          []int64
	IncludeMedia                 *bool
	IncludeTweetPublicMetrics    *bool
	IncludeTweetNonPublicMetrics *bool
	IncludeTweetOrganicMetrics   *bool
	IncludeMediaPublicMetrics    *bool
	IncludeMediaNonPublicMetrics *bool
	IncludeMediaOrganicMetrics   *bool
}

TweetsShowParams are the parameters for TweetsService.Show

type VideoNonPublicMetrics

type VideoNonPublicMetrics struct {
	ViewCount int `json:"view_count"`
}

type VideoOrganicMetrics

type VideoOrganicMetrics struct {
	ViewCount int `json:"view_count"`
}

type VideoPublicMetrics

type VideoPublicMetrics struct {
	ViewCount int `json:"view_count"`
}

Jump to

Keyboard shortcuts

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