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 ¶
- func Bool(v bool) *bool
- func Float(v float64) *float64
- type APIError
- type AccountService
- type AccountVerifyParams
- type Client
- type Contributor
- type Coordinates
- type Demux
- type DirectMessage
- type DirectMessageDestroyParams
- type DirectMessageGetParams
- type DirectMessageNewParams
- type DirectMessageSentParams
- type DirectMessageService
- func (s *DirectMessageService) Destroy(id int64, params *DirectMessageDestroyParams) (DirectMessage, *http.Response, error)
- func (s *DirectMessageService) Get(params *DirectMessageGetParams) ([]DirectMessage, *http.Response, error)
- func (s *DirectMessageService) New(params DirectMessageNewParams) (DirectMessage, *http.Response, error)
- func (s *DirectMessageService) SendToID(userID int64, text string) (DirectMessage, *http.Response, error)
- func (s *DirectMessageService) SendToScreenName(screenName, text string) (DirectMessage, *http.Response, error)
- func (s *DirectMessageService) Sent(params *DirectMessageSentParams) ([]DirectMessage, *http.Response, error)
- func (s *DirectMessageService) Show(id int64) ([]DirectMessage, *http.Response, error)
- type DirectMessageShowParams
- type Entities
- type ErrorDetail
- type Event
- type ExtendedEntity
- type FollowerIDParams
- type FollowerIDs
- type FollowerListParams
- type FollowerService
- type Followers
- type FriendsList
- type HashtagEntity
- type HomeTimelineParams
- type Indices
- type LocationDeletion
- type MediaEntity
- type MentionEntity
- type MentionTimelineParams
- type OEmbedTweet
- type RetweetsOfMeTimelineParams
- type StallWarning
- type StatusDeletion
- type StatusDestroyParams
- type StatusLookupParams
- type StatusOEmbedParams
- type StatusRetweetParams
- type StatusService
- func (s *StatusService) Destroy(id int64, params *StatusDestroyParams) (*Tweet, *http.Response, error)
- func (s *StatusService) Lookup(ids []int64, params *StatusLookupParams) ([]Tweet, *http.Response, error)
- func (s *StatusService) OEmbed(params *StatusOEmbedParams) (*OEmbedTweet, *http.Response, error)
- func (s *StatusService) Retweet(id int64, params *StatusRetweetParams) (*Tweet, *http.Response, error)
- func (s *StatusService) Show(id int64, params *StatusShowParams) (*Tweet, *http.Response, error)
- func (s *StatusService) Update(status string, params *StatusUpdateParams) (*Tweet, *http.Response, error)
- type StatusShowParams
- type StatusUpdateParams
- type StatusWithheld
- type Stream
- type StreamDisconnect
- type StreamFilterParams
- type StreamFirehoseParams
- type StreamLimit
- type StreamSampleParams
- type StreamService
- func (srv *StreamService) Filter(params *StreamFilterParams) (*Stream, error)
- func (srv *StreamService) Firehose(params *StreamFirehoseParams) (*Stream, error)
- func (srv *StreamService) Sample(params *StreamSampleParams) (*Stream, error)
- func (srv *StreamService) Site(params *StreamSiteParams) (*Stream, error)
- func (srv *StreamService) User(params *StreamUserParams) (*Stream, error)
- type StreamSiteParams
- type StreamUserParams
- type SwitchDemux
- type TimelineService
- func (s *TimelineService) HomeTimeline(params *HomeTimelineParams) ([]Tweet, *http.Response, error)
- func (s *TimelineService) MentionTimeline(params *MentionTimelineParams) ([]Tweet, *http.Response, error)
- func (s *TimelineService) RetweetsOfMeTimeline(params *RetweetsOfMeTimelineParams) ([]Tweet, *http.Response, error)
- func (s *TimelineService) UserTimeline(params *UserTimelineParams) ([]Tweet, *http.Response, error)
- type Tweet
- type TweetIdentifier
- type URLEntity
- type User
- type UserEntities
- type UserLookupParams
- type UserSearchParams
- type UserService
- type UserShowParams
- type UserTimelineParams
- type UserWithheld
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
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 Client ¶
type Client struct { // Twitter API Services Accounts *AccountService Statuses *StatusService Timelines *TimelineService Users *UserService Followers *FollowerService DirectMessages *DirectMessageService Streams *StreamService // contains filtered or unexported fields }
Client is a Twitter client for making Twitter API requests.
type Contributor ¶
type Contributor struct { ID int64 `json:"id"` IDStr string `json:"id_str"` ScreenName string `json:"screen_name"` }
Contributor represents a brief summary of a User identifiers.
type Coordinates ¶
Coordinates are pairs of longitude and latitude locations.
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.
type DirectMessageDestroyParams ¶
type DirectMessageDestroyParams struct { ID int64 `url:"id,omitempty"` IncludeEntities *bool `url:"include_entities,omitempty"` }
DirectMessageDestroyParams are the parameters for DirectMessageService.Destroy
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
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
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
type DirectMessageService ¶
type DirectMessageService struct {
// contains filtered or unexported fields
}
DirectMessageService provides methods for accessing Twitter status API endpoints.
func (*DirectMessageService) Destroy ¶
func (s *DirectMessageService) Destroy(id int64, params *DirectMessageDestroyParams) (DirectMessage, *http.Response, error)
Destroy deletes a direct message https://dev.twitter.com/rest/reference/get/direct_messages/new
func (*DirectMessageService) Get ¶
func (s *DirectMessageService) Get(params *DirectMessageGetParams) ([]DirectMessage, *http.Response, error)
Get returns the all the direct messages https://dev.twitter.com/rest/reference/get/direct_messages
func (*DirectMessageService) New ¶
func (s *DirectMessageService) New(params DirectMessageNewParams) (DirectMessage, *http.Response, error)
New creates a new direct message https://dev.twitter.com/rest/reference/get/direct_messages/new
func (*DirectMessageService) SendToID ¶
func (s *DirectMessageService) SendToID(userID int64, text string) (DirectMessage, *http.Response, error)
SendToID sends a direct message by twitter user id
func (*DirectMessageService) SendToScreenName ¶
func (s *DirectMessageService) SendToScreenName(screenName, text string) (DirectMessage, *http.Response, error)
SendToScreenName sends a message by twitter user id
func (*DirectMessageService) Sent ¶
func (s *DirectMessageService) Sent(params *DirectMessageSentParams) ([]DirectMessage, *http.Response, error)
Sent returns the all the direct messages sent https://dev.twitter.com/rest/reference/get/direct_messages/sent
func (*DirectMessageService) Show ¶
func (s *DirectMessageService) Show(id int64) ([]DirectMessage, *http.Response, error)
Show returns the requested DirectMessage and all response messages. https://dev.twitter.com/rest/reference/get/direct_messages/show
type DirectMessageShowParams ¶
type DirectMessageShowParams struct {
ID int64 `url:"id,omitempty"`
}
DirectMessageShowParams are the parameters for DirectMessageService.Show
type Entities ¶
type Entities struct { Media []MediaEntity `json:"media"` 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 ¶
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 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 int `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 ¶
func (s *FollowerService) IDs(params *FollowerIDParams) (*FollowerIDs, *http.Response, error)
IDs returns a cursored collection of user ids following the specified user. https://dev.twitter.com/rest/reference/get/followers/ids
func (*FollowerService) List ¶
func (s *FollowerService) List(params *FollowerListParams) (*Followers, *http.Response, error)
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 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 HashtagEntity ¶
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"` }
HomeTimelineParams are the parameters for TimelineService.HomeTimeline.
type Indices ¶
type Indices [2]int
Indices represent the start and end offsets within text.
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"` }
MediaEntity represents media elements associated with a Tweet. TODO: add 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"` }
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 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"` }
RetweetsOfMeTimelineParams are the parameters for TimelineService.RetweetsOfMeTimeline.
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"` }
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"` }
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"` }
StatusRetweetParams are the parameters for StatusService.Retweet
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 ¶
func (s *StatusService) OEmbed(params *StatusOEmbedParams) (*OEmbedTweet, *http.Response, error)
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) 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) 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"` }
StatusShowParams are the parameters for StatusService.Show
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"` }
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.
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:"location,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"`
}
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:"location,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 Tweet ¶
type Tweet struct { Contributors []Contributor `json:"contributors"` 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]string `json:"scopes"` Text string `json:"text"` 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"` 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 Unused or deprecated fields not provided: Geo, Annotations TODO: Place
type TweetIdentifier ¶
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:"id_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 ¶
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"` ContributorDetails *bool `url:"contributor_details,omitempty"` IncludeRetweets *bool `url:"include_rts,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