twitter

package
v0.0.0-...-42c42b3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package twitter provides a Client for the Twitter API.

The twitter package provides a Client for accessing the Twitter API. Here are some example requests.

// Twitter client
client := twitter.NewClient(httpClient)
// Home Timeline
tweets, resp, err := client.Timelines.HomeTimeline(&HomeTimelineParams{})
// Send a Tweet
tweet, resp, err := client.Statuses.Update("just setting up my twttr", nil)
// Status Show
tweet, resp, err := client.Statuses.Show(585613041028431872, nil)
// User Show
params := &twitter.UserShowParams{ScreenName: "dghubble"}
user, resp, err := client.Users.Show(params)
// Followers
followers, resp, err := client.Followers.List(&FollowerListParams{})

Required parameters are passed as positional arguments. Optional parameters are passed in a typed params struct (or pass nil).

Authentication

By design, the Twitter Client accepts any http.Client so user auth (OAuth1) or application auth (OAuth2) requests can be made by using the appropriate authenticated client. Use the https://github.com/dghubble/oauth1 and https://github.com/golang/oauth2 packages to obtain an http.Client which transparently authorizes requests.

For example, make requests as a consumer application on behalf of a user who has granted access, with OAuth1.

// OAuth1
import (
	"github.com/dghubble/go-twitter/twitter"
	"github.com/dghubble/oauth1"
)

config := oauth1.NewConfig("consumerKey", "consumerSecret")
token := oauth1.NewToken("accessToken", "accessSecret")
// http.Client will automatically authorize Requests
httpClient := config.Client(oauth1.NoContext, token)

// twitter client
client := twitter.NewClient(httpClient)

If no user auth context is needed, make requests as your application with application auth.

// OAuth2
import (
	"github.com/dghubble/go-twitter/twitter"
	"golang.org/x/oauth2"
)

config := &oauth2.Config{}
token := &oauth2.Token{AccessToken: accessToken}
// http.Client will automatically authorize Requests
httpClient := config.Client(oauth2.NoContext, token)

// twitter client
client := twitter.NewClient(httpClient)

To implement Login with Twitter, see https://github.com/dghubble/gologin.

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 AccountService

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

AccountService provides a method for account credential verification.

func (*AccountService) VerifyCredentials

func (s *AccountService) VerifyCredentials(params *AccountVerifyParams) (*User, *http.Response, error)

VerifyCredentials returns the authorized user if credentials are valid and returns an error otherwise. Requires a user auth context. https://dev.twitter.com/rest/reference/get/account/verify_credentials

type AccountVerifyParams

type AccountVerifyParams struct {
	IncludeEntities *bool `url:"include_entities,omitempty"`
	SkipStatus      *bool `url:"skip_status,omitempty"`
	IncludeEmail    *bool `url:"include_email,omitempty"`
}

AccountVerifyParams are the params for AccountService.VerifyCredentials.

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
	Accounts       *AccountService
	DirectMessages *DirectMessageService
	Favorites      *FavoriteService
	Followers      *FollowerService
	Friends        *FriendService
	Friendships    *FriendshipService
	Search         *SearchService
	Statuses       *StatusService
	Streams        *StreamService
	Timelines      *TimelineService
	Trends         *TrendsService
	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 ClosestParams

type ClosestParams struct {
	Lat  float64 `url:"lat"`
	Long float64 `url:"long"`
}

ClosestParams are the parameters for Trends.Closest.

type Coordinates

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

Coordinates are pairs of longitude and latitude locations.

type DMEventMessageData

type DMEventMessageData struct {
	Text       string                       `json:"text"`
	Entities   *Entities                    `json:"entities"`
	Attachment DMEventMessageDataAttachment `json:"attachment"`
}

DirectMessageEvents lists Direct Message events.

type DMEventMessageDataAttachment

type DMEventMessageDataAttachment struct {
	Type  string      `json:"type"`
	Media MediaEntity `json:"media"`
}

DirectMessageEvents lists Direct Message events.

type DMEventMessageTarget

type DMEventMessageTarget struct {
	RecipientID         string `json:"recipient_id"`
	RecipientScreenName string `json:"recipient_screen_name"`
}

DirectMessageEvents lists Direct Message events.

type Demux

type Demux interface {
	Handle(message interface{})
	HandleChan(messages <-chan interface{})
}

A Demux receives interface{} messages individually or from a channel and sends those messages to one or more outputs determined by the implementation.

type DirectMessage

type DirectMessage struct {
	CreatedAt           string    `json:"created_at"`
	Entities            *Entities `json:"entities"`
	ID                  int64     `json:"id"`
	IDStr               string    `json:"id_str"`
	Recipient           *User     `json:"recipient"`
	RecipientID         int64     `json:"recipient_id"`
	RecipientScreenName string    `json:"recipient_screen_name"`
	Sender              *User     `json:"sender"`
	SenderID            int64     `json:"sender_id"`
	SenderScreenName    string    `json:"sender_screen_name"`
	Text                string    `json:"text"`
}

DirectMessage is a direct message to a single recipient (DEPRECATED).

func (DirectMessage) CreatedAtTime

func (d DirectMessage) CreatedAtTime() (time.Time, error)

CreatedAtTime returns the time a Direct Message was created (DEPRECATED).

type DirectMessageDestroyParams

type DirectMessageDestroyParams struct {
	ID              int64 `url:"id,omitempty"`
	IncludeEntities *bool `url:"include_entities,omitempty"`
}

DirectMessageDestroyParams are the parameters for DirectMessageService.Destroy (DEPRECATED).

type DirectMessageEvent

type DirectMessageEvent struct {
	CreatedAt string                     `json:"created_timestamp"`
	ID        string                     `json:"id"`
	Type      string                     `json:"type"`
	Message   *DirectMessageEventMessage `json:"message_create"`
}

DirectMessageEvent is a single Direct Message sent or received.

func (DirectMessageEvent) CreatedAtTime

func (d DirectMessageEvent) CreatedAtTime() (date time.Time, err error)

CreatedAtTime returns the UTC time a Direct Message was created from Twitter's timestamp.

type DirectMessageEventMessage

type DirectMessageEventMessage struct {
	SenderID         string               `json:"sender_id"`
	SenderScreenName string               `json:"sender_screen_name"`
	Target           DMEventMessageTarget `json:"target"`
	Data             DMEventMessageData   `json:"message_data"`
}

DirectMessageEventMessage contains message contents, along with sender and target recipient.

type DirectMessageEvents

type DirectMessageEvents struct {
	Events     []DirectMessageEvent `json:"events"`
	NextCursor string               `json:"next_cursor"`
}

DirectMessageEvents lists Direct Message events.

type DirectMessageEventsCreateResponse

type DirectMessageEventsCreateResponse struct {
	Event DirectMessageEvent
}

DirectMessageEventsCreateResponse represents the data structure returned by the Twitter API after the successful creation of an event

type DirectMessageEventsListParams

type DirectMessageEventsListParams struct {
	Cursor string `url:"cursor,omitempty"`
	Count  int    `url:"count,omitempty"`
}

DirectMessageEventsListParams are the parameters for DirectMessageService.EventsList

type DirectMessageGetParams

type DirectMessageGetParams struct {
	SinceID         int64 `url:"since_id,omitempty"`
	MaxID           int64 `url:"max_id,omitempty"`
	Count           int   `url:"count,omitempty"`
	IncludeEntities *bool `url:"include_entities,omitempty"`
	SkipStatus      *bool `url:"skip_status,omitempty"`
}

DirectMessageGetParams are the parameters for DirectMessageService.Get (DEPRECATED).

type DirectMessageNewParams

type DirectMessageNewParams struct {
	UserID     int64  `url:"user_id,omitempty"`
	ScreenName string `url:"screen_name,omitempty"`
	Text       string `url:"text"`
}

DirectMessageNewParams are the parameters for DirectMessageService.New (DEPRECATED).

type DirectMessageSentParams

type DirectMessageSentParams struct {
	SinceID         int64 `url:"since_id,omitempty"`
	MaxID           int64 `url:"max_id,omitempty"`
	Count           int   `url:"count,omitempty"`
	Page            int   `url:"page,omitempty"`
	IncludeEntities *bool `url:"include_entities,omitempty"`
}

DirectMessageSentParams are the parameters for DirectMessageService.Sent (DEPRECATED).

type DirectMessageService

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

DirectMessageService provides methods for accessing Twitter direct message API endpoints.

func (*DirectMessageService) Destroy

Destroy deletes the Direct Message with the given id and returns it if successful (DEPRECATED). Requires a user auth context with DM scope. https://dev.twitter.com/rest/reference/post/direct_messages/destroy

func (*DirectMessageService) EventsCreate

EventsCreate creates a new Direct Message event

func (*DirectMessageService) EventsList

EventsList returns Direct Message events (both sent and received) within the last 30 days in reverse chronological order. Requires a user auth context with DM scope. https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/list-events

func (*DirectMessageService) Get

Get returns recent Direct Messages received by the authenticated user (DEPRECATED). Requires a user auth context with DM scope. https://dev.twitter.com/rest/reference/get/direct_messages

func (*DirectMessageService) New

New sends a new Direct Message to a specified user as the authenticated user (DEPRECATED). Requires a user auth context with DM scope. https://dev.twitter.com/rest/reference/post/direct_messages/new

func (*DirectMessageService) Sent

Sent returns recent Direct Messages sent by the authenticated user (DEPRECATED). Requires a user auth context with DM scope. https://dev.twitter.com/rest/reference/get/direct_messages/sent

func (*DirectMessageService) Show

Show returns the requested Direct Message (DEPRECATED). Requires a user auth context with DM scope. https://dev.twitter.com/rest/reference/get/direct_messages/show

type Entities

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

Entities represent metadata and context info parsed from Twitter components. https://dev.twitter.com/overview/api/entities TODO: symbols

type ErrorDetail

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

ErrorDetail represents an individual item in an APIError.

type Event

type Event struct {
	Event     string `json:"event"`
	CreatedAt string `json:"created_at"`
	Target    *User  `json:"target"`
	Source    *User  `json:"source"`
	// TODO: add List or deprecate it
	TargetObject *Tweet `json:"target_object"`
}

Event is a non-Tweet notification message (e.g. like, retweet, follow). https://dev.twitter.com/streaming/overview/messages-types#Events_event

type ExtendedEntity

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

ExtendedEntity contains media information. https://dev.twitter.com/overview/api/entities-in-twitter-objects#extended_entities

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 FavoriteCreateParams

type FavoriteCreateParams struct {
	ID int64 `url:"id,omitempty"`
}

FavoriteCreateParams are the parameters for FavoriteService.Create.

type FavoriteDestroyParams

type FavoriteDestroyParams struct {
	ID int64 `url:"id,omitempty"`
}

FavoriteDestroyParams are the parameters for FavoriteService.Destroy.

type FavoriteListParams

type FavoriteListParams struct {
	UserID          int64  `url:"user_id,omitempty"`
	ScreenName      string `url:"screen_name,omitempty"`
	Count           int    `url:"count,omitempty"`
	SinceID         int64  `url:"since_id,omitempty"`
	MaxID           int64  `url:"max_id,omitempty"`
	IncludeEntities *bool  `url:"include_entities,omitempty"`
	TweetMode       string `url:"tweet_mode,omitempty"`
}

FavoriteListParams are the parameters for FavoriteService.List.

type FavoriteService

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

FavoriteService provides methods for accessing Twitter favorite API endpoints.

Note: the like action was known as favorite before November 3, 2015; the historical naming remains in API methods and object properties.

func (*FavoriteService) Create

func (s *FavoriteService) Create(params *FavoriteCreateParams) (*Tweet, *http.Response, error)

Create favorites the specified tweet. Requires a user auth context. https://dev.twitter.com/rest/reference/post/favorites/create

func (*FavoriteService) Destroy

func (s *FavoriteService) Destroy(params *FavoriteDestroyParams) (*Tweet, *http.Response, error)

Destroy un-favorites the specified tweet. Requires a user auth context. https://dev.twitter.com/rest/reference/post/favorites/destroy

func (*FavoriteService) List

func (s *FavoriteService) List(params *FavoriteListParams) ([]Tweet, *http.Response, error)

List returns liked Tweets from the specified user. https://dev.twitter.com/rest/reference/get/favorites/list

type FollowerIDParams

type FollowerIDParams struct {
	UserID     int64  `url:"user_id,omitempty"`
	ScreenName string `url:"screen_name,omitempty"`
	Cursor     int64  `url:"cursor,omitempty"`
	Count      int    `url:"count,omitempty"`
}

FollowerIDParams are the parameters for FollowerService.Ids

type FollowerIDs

type FollowerIDs struct {
	IDs               []int64 `json:"ids"`
	NextCursor        int64   `json:"next_cursor"`
	NextCursorStr     string  `json:"next_cursor_str"`
	PreviousCursor    int64   `json:"previous_cursor"`
	PreviousCursorStr string  `json:"previous_cursor_str"`
}

FollowerIDs is a cursored collection of follower ids.

type FollowerListParams

type FollowerListParams struct {
	UserID              int64  `url:"user_id,omitempty"`
	ScreenName          string `url:"screen_name,omitempty"`
	Cursor              int64  `url:"cursor,omitempty"`
	Count               int    `url:"count,omitempty"`
	SkipStatus          *bool  `url:"skip_status,omitempty"`
	IncludeUserEntities *bool  `url:"include_user_entities,omitempty"`
}

FollowerListParams are the parameters for FollowerService.List

type FollowerService

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

FollowerService provides methods for accessing Twitter followers endpoints.

func (*FollowerService) IDs

IDs returns a cursored collection of user ids following the specified user. https://dev.twitter.com/rest/reference/get/followers/ids

func (*FollowerService) List

List returns a cursored collection of Users following the specified user. https://dev.twitter.com/rest/reference/get/followers/list

type Followers

type Followers struct {
	Users             []User `json:"users"`
	NextCursor        int64  `json:"next_cursor"`
	NextCursorStr     string `json:"next_cursor_str"`
	PreviousCursor    int64  `json:"previous_cursor"`
	PreviousCursorStr string `json:"previous_cursor_str"`
}

Followers is a cursored collection of followers.

type FriendIDParams

type FriendIDParams struct {
	UserID     int64  `url:"user_id,omitempty"`
	ScreenName string `url:"screen_name,omitempty"`
	Cursor     int64  `url:"cursor,omitempty"`
	Count      int    `url:"count,omitempty"`
}

FriendIDParams are the parameters for FriendService.Ids

type FriendIDs

type FriendIDs struct {
	IDs               []int64 `json:"ids"`
	NextCursor        int64   `json:"next_cursor"`
	NextCursorStr     string  `json:"next_cursor_str"`
	PreviousCursor    int64   `json:"previous_cursor"`
	PreviousCursorStr string  `json:"previous_cursor_str"`
}

FriendIDs is a cursored collection of friend ids.

type FriendListParams

type FriendListParams struct {
	UserID              int64  `url:"user_id,omitempty"`
	ScreenName          string `url:"screen_name,omitempty"`
	Cursor              int64  `url:"cursor,omitempty"`
	Count               int    `url:"count,omitempty"`
	SkipStatus          *bool  `url:"skip_status,omitempty"`
	IncludeUserEntities *bool  `url:"include_user_entities,omitempty"`
}

FriendListParams are the parameters for FriendService.List

type FriendService

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

FriendService provides methods for accessing Twitter friends endpoints.

func (*FriendService) IDs

func (s *FriendService) IDs(params *FriendIDParams) (*FriendIDs, *http.Response, error)

IDs returns a cursored collection of user ids that the specified user is following. https://dev.twitter.com/rest/reference/get/friends/ids

func (*FriendService) List

func (s *FriendService) List(params *FriendListParams) (*Friends, *http.Response, error)

List returns a cursored collection of Users that the specified user is following. https://dev.twitter.com/rest/reference/get/friends/list

type Friends

type Friends struct {
	Users             []User `json:"users"`
	NextCursor        int64  `json:"next_cursor"`
	NextCursorStr     string `json:"next_cursor_str"`
	PreviousCursor    int64  `json:"previous_cursor"`
	PreviousCursorStr string `json:"previous_cursor_str"`
}

Friends is a cursored collection of friends.

type FriendsList

type FriendsList struct {
	Friends []int64 `json:"friends"`
}

FriendsList is a list of some of a user's friends. https://dev.twitter.com/streaming/overview/messages-types#friends_list_friends

type FriendshipCreateParams

type FriendshipCreateParams struct {
	ScreenName string `url:"screen_name,omitempty"`
	UserID     int64  `url:"user_id,omitempty"`
	Follow     *bool  `url:"follow,omitempty"`
}

FriendshipCreateParams are parameters for FriendshipService.Create

type FriendshipDestroyParams

type FriendshipDestroyParams struct {
	ScreenName string `url:"screen_name,omitempty"`
	UserID     int64  `url:"user_id,omitempty"`
}

FriendshipDestroyParams are paramenters for FriendshipService.Destroy

type FriendshipPendingParams

type FriendshipPendingParams struct {
	Cursor int64 `url:"cursor,omitempty"`
}

FriendshipPendingParams are paramenters for FriendshipService.Outgoing

type FriendshipService

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

FriendshipService provides methods for accessing Twitter friendship API endpoints.

func (*FriendshipService) Create

Create creates a friendship to (i.e. follows) the specified user and returns the followed user. Requires a user auth context. https://dev.twitter.com/rest/reference/post/friendships/create

func (*FriendshipService) Destroy

Destroy destroys a friendship to (i.e. unfollows) the specified user and returns the unfollowed user. Requires a user auth context. https://dev.twitter.com/rest/reference/post/friendships/destroy

func (*FriendshipService) Incoming

Incoming returns a collection of numeric IDs for every user who has a pending request to follow the authenticating user. https://dev.twitter.com/rest/reference/get/friendships/incoming

func (*FriendshipService) Outgoing

Outgoing returns a collection of numeric IDs for every protected user for whom the authenticating user has a pending follow request. https://dev.twitter.com/rest/reference/get/friendships/outgoing

func (*FriendshipService) Show

Show returns the relationship between two arbitrary users. Requires a user auth or an app context. https://dev.twitter.com/rest/reference/get/friendships/show

type FriendshipShowParams

type FriendshipShowParams struct {
	SourceID         int64  `url:"source_id,omitempty"`
	SourceScreenName string `url:"source_screen_name,omitempty"`
	TargetID         int64  `url:"target_id,omitempty"`
	TargetScreenName string `url:"target_screen_name,omitempty"`
}

FriendshipShowParams are paramenters for FriendshipService.Show

type HashtagEntity

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

HashtagEntity represents a hashtag which has been parsed from text.

type HomeTimelineParams

type HomeTimelineParams struct {
	Count              int    `url:"count,omitempty"`
	SinceID            int64  `url:"since_id,omitempty"`
	MaxID              int64  `url:"max_id,omitempty"`
	TrimUser           *bool  `url:"trim_user,omitempty"`
	ExcludeReplies     *bool  `url:"exclude_replies,omitempty"`
	ContributorDetails *bool  `url:"contributor_details,omitempty"`
	IncludeEntities    *bool  `url:"include_entities,omitempty"`
	TweetMode          string `url:"tweet_mode,omitempty"`
}

HomeTimelineParams are the parameters for TimelineService.HomeTimeline.

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 Location

type Location struct {
	Country     string    `json:"country"`
	CountryCode string    `json:"countryCode"`
	Name        string    `json:"name"`
	ParentID    int       `json:"parentid"`
	PlaceType   PlaceType `json:"placeType"`
	URL         string    `json:"url"`
	WOEID       int64     `json:"woeid"`
}

Location represents a twitter Location.

type LocationDeletion

type LocationDeletion struct {
	UserID          int64  `json:"user_id"`
	UserIDStr       string `json:"user_id_str"`
	UpToStatusID    int64  `json:"up_to_status_id"`
	UpToStatusIDStr string `json:"up_to_status_id_str"`
}

LocationDeletion indicates geolocation data must be stripped from a range of Tweets. https://dev.twitter.com/streaming/overview/messages-types#Location_deletion_notices_scrub_geo

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://dev.twitter.com/overview/api/entities#obj-sizes

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 MentionTimelineParams

type MentionTimelineParams struct {
	Count              int    `url:"count,omitempty"`
	SinceID            int64  `url:"since_id,omitempty"`
	MaxID              int64  `url:"max_id,omitempty"`
	TrimUser           *bool  `url:"trim_user,omitempty"`
	ContributorDetails *bool  `url:"contributor_details,omitempty"`
	IncludeEntities    *bool  `url:"include_entities,omitempty"`
	TweetMode          string `url:"tweet_mode,omitempty"`
}

MentionTimelineParams are the parameters for TimelineService.MentionTimeline.

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 PlaceType

type PlaceType struct {
	Code int    `json:"code"`
	Name string `json:"name"`
}

PlaceType represents a twitter trends PlaceType.

type Relationship

type Relationship struct {
	Source RelationshipSource `json:"source"`
	Target RelationshipTarget `json:"target"`
}

Relationship represents the relation between a source user and target user.

type RelationshipResponse

type RelationshipResponse struct {
	Relationship *Relationship `json:"relationship"`
}

RelationshipResponse contains a relationship.

type RelationshipSource

type RelationshipSource struct {
	ID                   int64  `json:"id"`
	IDStr                string `json:"id_str"`
	ScreenName           string `json:"screen_name"`
	Following            bool   `json:"following"`
	FollowedBy           bool   `json:"followed_by"`
	CanDM                bool   `json:"can_dm"`
	Blocking             bool   `json:"blocking"`
	Muting               bool   `json:"muting"`
	AllReplies           bool   `json:"all_replies"`
	WantRetweets         bool   `json:"want_retweets"`
	MarkedSpam           bool   `json:"marked_spam"`
	NotificationsEnabled bool   `json:"notifications_enabled"`
}

RelationshipSource represents the source user.

type RelationshipTarget

type RelationshipTarget struct {
	ID         int64  `json:"id"`
	IDStr      string `json:"id_str"`
	ScreenName string `json:"screen_name"`
	Following  bool   `json:"following"`
	FollowedBy bool   `json:"followed_by"`
}

RelationshipTarget represents the target user.

type RetweetsOfMeTimelineParams

type RetweetsOfMeTimelineParams struct {
	Count               int    `url:"count,omitempty"`
	SinceID             int64  `url:"since_id,omitempty"`
	MaxID               int64  `url:"max_id,omitempty"`
	TrimUser            *bool  `url:"trim_user,omitempty"`
	IncludeEntities     *bool  `url:"include_entities,omitempty"`
	IncludeUserEntities *bool  `url:"include_user_entities"`
	TweetMode           string `url:"tweet_mode,omitempty"`
}

RetweetsOfMeTimelineParams are the parameters for TimelineService.RetweetsOfMeTimeline.

type Search struct {
	Statuses []Tweet         `json:"statuses"`
	Metadata *SearchMetadata `json:"search_metadata"`
}

Search represents the result of a Tweet search.

type SearchMetadata

type SearchMetadata struct {
	Count       int     `json:"count"`
	SinceID     int64   `json:"since_id"`
	SinceIDStr  string  `json:"since_id_str"`
	MaxID       int64   `json:"max_id"`
	MaxIDStr    string  `json:"max_id_str"`
	RefreshURL  string  `json:"refresh_url"`
	NextResults string  `json:"next_results"`
	CompletedIn float64 `json:"completed_in"`
	Query       string  `json:"query"`
}

SearchMetadata describes a Search result.

type SearchService

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

SearchService provides methods for accessing Twitter search API endpoints.

func (*SearchService) Tweets

func (s *SearchService) Tweets(params *SearchTweetParams) (*Search, *http.Response, error)

Tweets returns a collection of Tweets matching a search query. https://dev.twitter.com/rest/reference/get/search/tweets

type SearchTweetParams

type SearchTweetParams struct {
	Query           string `url:"q,omitempty"`
	Geocode         string `url:"geocode,omitempty"`
	Lang            string `url:"lang,omitempty"`
	Locale          string `url:"locale,omitempty"`
	ResultType      string `url:"result_type,omitempty"`
	Count           int    `url:"count,omitempty"`
	SinceID         int64  `url:"since_id,omitempty"`
	MaxID           int64  `url:"max_id,omitempty"`
	Until           string `url:"until,omitempty"`
	IncludeEntities *bool  `url:"include_entities,omitempty"`
	TweetMode       string `url:"tweet_mode,omitempty"`
}

SearchTweetParams are the parameters for SearchService.Tweets

type StallWarning

type StallWarning struct {
	Code        string `json:"code"`
	Message     string `json:"message"`
	PercentFull int    `json:"percent_full"`
}

StallWarning indicates the client is falling behind in the stream. https://dev.twitter.com/streaming/overview/messages-types#stall_warnings

type StatusDeletion

type StatusDeletion struct {
	ID        int64  `json:"id"`
	IDStr     string `json:"id_str"`
	UserID    int64  `json:"user_id"`
	UserIDStr string `json:"user_id_str"`
}

StatusDeletion indicates that a given Tweet has been deleted. https://dev.twitter.com/streaming/overview/messages-types#status_deletion_notices_delete

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 StatusWithheld

type StatusWithheld struct {
	ID                  int64    `json:"id"`
	UserID              int64    `json:"user_id"`
	WithheldInCountries []string `json:"withheld_in_countries"`
}

StatusWithheld indicates a Tweet with the given ID, belonging to UserId, has been withheld in certain countries. https://dev.twitter.com/streaming/overview/messages-types#withheld_content_notices

type Stream

type Stream struct {
	Messages chan interface{}
	// contains filtered or unexported fields
}

Stream maintains a connection to the Twitter Streaming API, receives messages from the streaming response, and sends them on the Messages channel from a goroutine. The stream goroutine stops itself if an EOF is reached or retry errors occur, also closing the Messages channel.

The client must Stop() the stream when finished receiving, which will wait until the stream is properly stopped.

func (*Stream) Stop

func (s *Stream) Stop()

Stop signals retry and receiver to stop, closes the Messages channel, and blocks until done.

type StreamDisconnect

type StreamDisconnect struct {
	Code       int64  `json:"code"`
	StreamName string `json:"stream_name"`
	Reason     string `json:"reason"`
}

StreamDisconnect indicates the stream has been shutdown for some reason. https://dev.twitter.com/streaming/overview/messages-types#disconnect_messages

type StreamFilterParams

type StreamFilterParams struct {
	FilterLevel   string   `url:"filter_level,omitempty"`
	Follow        []string `url:"follow,omitempty,comma"`
	Language      []string `url:"language,omitempty,comma"`
	Locations     []string `url:"locations,omitempty,comma"`
	StallWarnings *bool    `url:"stall_warnings,omitempty"`
	Track         []string `url:"track,omitempty,comma"`
}

StreamFilterParams are parameters for StreamService.Filter.

type StreamFirehoseParams

type StreamFirehoseParams struct {
	Count         int      `url:"count,omitempty"`
	FilterLevel   string   `url:"filter_level,omitempty"`
	Language      []string `url:"language,omitempty,comma"`
	StallWarnings *bool    `url:"stall_warnings,omitempty"`
}

StreamFirehoseParams are the parameters for StreamService.Firehose.

type StreamLimit

type StreamLimit struct {
	Track int64 `json:"track"`
}

StreamLimit indicates a stream matched more statuses than its rate limit allowed. The track number is the number of undelivered matches. https://dev.twitter.com/streaming/overview/messages-types#limit_notices

type StreamSampleParams

type StreamSampleParams struct {
	StallWarnings *bool    `url:"stall_warnings,omitempty"`
	Language      []string `url:"language,omitempty,comma"`
}

StreamSampleParams are the parameters for StreamService.Sample.

type StreamService

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

StreamService provides methods for accessing the Twitter Streaming API.

func (*StreamService) Filter

func (srv *StreamService) Filter(params *StreamFilterParams) (*Stream, error)

Filter returns messages that match one or more filter predicates. https://dev.twitter.com/streaming/reference/post/statuses/filter

func (*StreamService) Firehose

func (srv *StreamService) Firehose(params *StreamFirehoseParams) (*Stream, error)

Firehose returns all public messages and statuses. Requires special permission to access. https://dev.twitter.com/streaming/reference/get/statuses/firehose

func (*StreamService) Sample

func (srv *StreamService) Sample(params *StreamSampleParams) (*Stream, error)

Sample returns a small sample of public stream messages. https://dev.twitter.com/streaming/reference/get/statuses/sample

func (*StreamService) Site

func (srv *StreamService) Site(params *StreamSiteParams) (*Stream, error)

Site returns messages for a set of users. Requires special permission to access. https://dev.twitter.com/streaming/reference/get/site

func (*StreamService) User

func (srv *StreamService) User(params *StreamUserParams) (*Stream, error)

User returns a stream of messages specific to the authenticated User. https://dev.twitter.com/streaming/reference/get/user

type StreamSiteParams

type StreamSiteParams struct {
	FilterLevel   string   `url:"filter_level,omitempty"`
	Follow        []string `url:"follow,omitempty,comma"`
	Language      []string `url:"language,omitempty,comma"`
	Replies       string   `url:"replies,omitempty"`
	StallWarnings *bool    `url:"stall_warnings,omitempty"`
	With          string   `url:"with,omitempty"`
}

StreamSiteParams are the parameters for StreamService.Site.

type StreamUserParams

type StreamUserParams struct {
	FilterLevel   string   `url:"filter_level,omitempty"`
	Language      []string `url:"language,omitempty,comma"`
	Locations     []string `url:"locations,omitempty,comma"`
	Replies       string   `url:"replies,omitempty"`
	StallWarnings *bool    `url:"stall_warnings,omitempty"`
	Track         []string `url:"track,omitempty,comma"`
	With          string   `url:"with,omitempty"`
}

StreamUserParams are the parameters for StreamService.User.

type SwitchDemux

type SwitchDemux struct {
	All              func(message interface{})
	Tweet            func(tweet *Tweet)
	DM               func(dm *DirectMessage)
	StatusDeletion   func(deletion *StatusDeletion)
	LocationDeletion func(LocationDeletion *LocationDeletion)
	StreamLimit      func(limit *StreamLimit)
	StatusWithheld   func(statusWithheld *StatusWithheld)
	UserWithheld     func(userWithheld *UserWithheld)
	StreamDisconnect func(disconnect *StreamDisconnect)
	Warning          func(warning *StallWarning)
	FriendsList      func(friendsList *FriendsList)
	Event            func(event *Event)
	Other            func(message interface{})
}

SwitchDemux receives messages and uses a type switch to send each typed message to a handler function.

func NewSwitchDemux

func NewSwitchDemux() SwitchDemux

NewSwitchDemux returns a new SwitchMux which has NoOp handler functions.

func (SwitchDemux) Handle

func (d SwitchDemux) Handle(message interface{})

Handle determines the type of a message and calls the corresponding receiver function with the typed message. All messages are passed to the All func. Messages with unmatched types are passed to the Other func.

func (SwitchDemux) HandleChan

func (d SwitchDemux) HandleChan(messages <-chan interface{})

HandleChan receives messages and calls the corresponding receiver function with the typed message. All messages are passed to the All func. Messages with unmatched type are passed to the Other func.

type TimelineService

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

TimelineService provides methods for accessing Twitter status timeline API endpoints.

func (*TimelineService) HomeTimeline

func (s *TimelineService) HomeTimeline(params *HomeTimelineParams) ([]Tweet, *http.Response, error)

HomeTimeline returns recent Tweets and retweets from the user and those users they follow. Requires a user auth context. https://dev.twitter.com/rest/reference/get/statuses/home_timeline

func (*TimelineService) MentionTimeline

func (s *TimelineService) MentionTimeline(params *MentionTimelineParams) ([]Tweet, *http.Response, error)

MentionTimeline returns recent Tweet mentions of the authenticated user. Requires a user auth context. https://dev.twitter.com/rest/reference/get/statuses/mentions_timeline

func (*TimelineService) RetweetsOfMeTimeline

func (s *TimelineService) RetweetsOfMeTimeline(params *RetweetsOfMeTimelineParams) ([]Tweet, *http.Response, error)

RetweetsOfMeTimeline returns the most recent Tweets by the authenticated user that have been retweeted by others. Requires a user auth context. https://dev.twitter.com/rest/reference/get/statuses/retweets_of_me

func (*TimelineService) UserTimeline

func (s *TimelineService) UserTimeline(params *UserTimelineParams) ([]Tweet, *http.Response, error)

UserTimeline returns recent Tweets from the specified user. https://dev.twitter.com/rest/reference/get/statuses/user_timeline

type Trend

type Trend struct {
	Name            string `json:"name"`
	URL             string `json:"url"`
	PromotedContent string `json:"promoted_content"`
	Query           string `json:"query"`
	TweetVolume     int64  `json:"tweet_volume"`
}

Trend represents a twitter trend.

type TrendsList

type TrendsList struct {
	Trends    []Trend          `json:"trends"`
	AsOf      string           `json:"as_of"`
	CreatedAt string           `json:"created_at"`
	Locations []TrendsLocation `json:"locations"`
}

TrendsList represents a list of twitter trends.

type TrendsLocation

type TrendsLocation struct {
	Name  string `json:"name"`
	WOEID int64  `json:"woeid"`
}

TrendsLocation represents a twitter trend location.

type TrendsPlaceParams

type TrendsPlaceParams struct {
	WOEID   int64  `url:"id,omitempty"`
	Exclude string `url:"exclude,omitempty"`
}

TrendsPlaceParams are the parameters for Trends.Place.

type TrendsService

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

TrendsService provides methods for accessing Twitter trends API endpoints.

func (*TrendsService) Available

func (s *TrendsService) Available() ([]Location, *http.Response, error)

Available returns the locations that Twitter has trending topic information for. https://dev.twitter.com/rest/reference/get/trends/available

func (*TrendsService) Closest

func (s *TrendsService) Closest(params *ClosestParams) ([]Location, *http.Response, error)

Closest returns the locations that Twitter has trending topic information for, closest to a specified location. https://dev.twitter.com/rest/reference/get/trends/closest

func (*TrendsService) Place

func (s *TrendsService) Place(woeid int64, params *TrendsPlaceParams) ([]TrendsList, *http.Response, error)

Place returns the top 50 trending topics for a specific WOEID. https://dev.twitter.com/rest/reference/get/trends/place

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"`
	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://dev.twitter.com/overview/api/entities-in-twitter-objects#users

type UserLookupParams

type UserLookupParams struct {
	UserID          []int64  `url:"user_id,omitempty,comma"`
	ScreenName      []string `url:"screen_name,omitempty,comma"`
	IncludeEntities *bool    `url:"include_entities,omitempty"` // whether 'status' should include entities
}

UserLookupParams are the parameters for UserService.Lookup.

type UserSearchParams

type UserSearchParams struct {
	Query           string `url:"q,omitempty"`
	Page            int    `url:"page,omitempty"` // 1-based page number
	Count           int    `url:"count,omitempty"`
	IncludeEntities *bool  `url:"include_entities,omitempty"` // whether 'status' should include entities
}

UserSearchParams are the parameters for UserService.Search.

type UserService

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

UserService provides methods for accessing Twitter user API endpoints.

func (*UserService) Lookup

func (s *UserService) Lookup(params *UserLookupParams) ([]User, *http.Response, error)

Lookup returns the requested Users as a slice. https://dev.twitter.com/rest/reference/get/users/lookup

func (*UserService) Search

func (s *UserService) Search(query string, params *UserSearchParams) ([]User, *http.Response, error)

Search queries public user accounts. Requires a user auth context. https://dev.twitter.com/rest/reference/get/users/search

func (*UserService) Show

func (s *UserService) Show(params *UserShowParams) (*User, *http.Response, error)

Show returns the requested User. https://dev.twitter.com/rest/reference/get/users/show

type UserShowParams

type UserShowParams struct {
	UserID          int64  `url:"user_id,omitempty"`
	ScreenName      string `url:"screen_name,omitempty"`
	IncludeEntities *bool  `url:"include_entities,omitempty"` // whether 'status' should include entities
}

UserShowParams are the parameters for UserService.Show.

type UserTimelineParams

type UserTimelineParams struct {
	UserID          int64  `url:"user_id,omitempty"`
	ScreenName      string `url:"screen_name,omitempty"`
	Count           int    `url:"count,omitempty"`
	SinceID         int64  `url:"since_id,omitempty"`
	MaxID           int64  `url:"max_id,omitempty"`
	TrimUser        *bool  `url:"trim_user,omitempty"`
	ExcludeReplies  *bool  `url:"exclude_replies,omitempty"`
	IncludeRetweets *bool  `url:"include_rts,omitempty"`
	TweetMode       string `url:"tweet_mode,omitempty"`
}

UserTimelineParams are the parameters for TimelineService.UserTimeline.

type UserWithheld

type UserWithheld struct {
	ID                  int64    `json:"id"`
	WithheldInCountries []string `json:"withheld_in_countries"`
}

UserWithheld indicates a User with the given ID has been withheld in certain countries. https://dev.twitter.com/streaming/overview/messages-types#withheld_content_notices

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