Documentation ¶
Index ¶
- Constants
- func LoadArchive(base string) (*twitterpb.Archive, error)
- type ApiError
- type Archiver
- type CSVTweet
- type DirectMessageEventsResp
- type ListsOwnershipsResp
- type Reader
- type TwitterApi
- func (a TwitterApi) GetDirectMessageEvents(params url.Values) (DirectMessageEventsResp, error)
- func (a TwitterApi) GetFavorites(params url.Values) ([]*twitterpb.Tweet, error)
- func (a TwitterApi) GetFollowers(params url.Values) (UsersResp, error)
- func (a TwitterApi) GetFriends(params url.Values) (UsersResp, error)
- func (a TwitterApi) GetListsOwnedBy(params url.Values) (ListsOwnershipsResp, error)
- func (a TwitterApi) GetMembers(params url.Values) (UsersResp, error)
- func (a TwitterApi) GetUserTimeline(params url.Values) ([]*twitterpb.Tweet, error)
- func (a TwitterApi) LookupStatuses(params url.Values) ([]*twitterpb.Tweet, error)
- func (c *TwitterApi) SetDelay(t time.Duration)
- type TwitterError
- type TwitterErrorResponse
- type UsersResp
Constants ¶
const ( ClientTimeout = 20 BaseUrlV1 = "https://api.twitter.com/1" BaseUrl = "https://api.twitter.com/1.1" UploadBaseUrl = "https://upload.twitter.com/1.1" DEFAULT_DELAY = 0 * time.Second EFAULT_CAPACITY = 5 )
const ( //Error code defintions match the Twitter documentation //https://developer.twitter.com/en/docs/basics/response-codes TwitterErrorCouldNotAuthenticate = 32 TwitterErrorDoesNotExist = 34 TwitterErrorAccountSuspended = 64 TwitterErrorApi1Deprecation = 68 //This should never be needed TwitterErrorRateLimitExceeded = 88 TwitterErrorInvalidToken = 89 TwitterErrorOverCapacity = 130 TwitterErrorInternalError = 131 TwitterErrorCouldNotAuthenticateYou = 135 TwitterErrorStatusIsADuplicate = 187 TwitterErrorBadAuthenticationData = 215 TwitterErrorUserMustVerifyLogin = 231 // Undocumented by Twitter, but may be returned instead of 34 TwitterErrorDoesNotExist2 = 144 )
const ( FilenameDirectMessages = "dms.json" FilenameFavorites = "favorites.json" FilenameFollowers = "followers.json" FilenameFriends = "friends.json" FilenameLists = "lists.json" FilenameTimeline = "tweets.json" )
Variables ¶
This section is empty.
Functions ¶
func LoadArchive ¶
Types ¶
type ApiError ¶
type ApiError struct { StatusCode int Header http.Header Body string Decoded TwitterErrorResponse URL *url.URL }
func (*ApiError) RateLimitCheck ¶
Check to see if an error is a Rate Limiting error. If so, find the next available window in the header. Use like so:
if aerr, ok := err.(*ApiError); ok { if isRateLimitError, nextWindow := aerr.RateLimitCheck(); isRateLimitError { <-time.After(nextWindow.Sub(time.Now())) } }
type DirectMessageEventsResp ¶
type DirectMessageEventsResp struct { NextCursor string `json:"next_cursor"` Events []*twitterpb.DirectMessageEvent `json:"events"` }
"{\"type\":\"message_create\",\"id\":\"1005146433668841476\",\"created_timestamp\":\"1528480559161\",\"message_create\":{\"target\":{\"recipient_id\":\"86892924\"},\"sender_id\":\"160248151\",\"source_app_id\":\"268278\",\"message_data\":{\"text\":\"Sorry for the random Twitter message, I need to test out the DM API\",\"entities\":{\"hashtags\":[],\"symbols\":[],\"user_mentions\":[],\"urls\":[]}}}}"
type ListsOwnershipsResp ¶
type TwitterApi ¶
type TwitterApi struct { Credentials *oauth.Credentials HttpClient *http.Client // contains filtered or unexported fields }
func NewTwitterApi ¶
func NewTwitterApi(access_token, access_token_secret, consumer_key, consumer_secret string) *TwitterApi
NewTwitterApi takes an user-specific access token and secret and returns a TwitterApi struct for that user. The TwitterApi struct can be used for accessing any of the endpoints available.
func (TwitterApi) GetDirectMessageEvents ¶
func (a TwitterApi) GetDirectMessageEvents(params url.Values) (DirectMessageEventsResp, error)
func (TwitterApi) GetFavorites ¶
func (a TwitterApi) GetFavorites(params url.Values) ([]*twitterpb.Tweet, error)
func (TwitterApi) GetFollowers ¶
func (a TwitterApi) GetFollowers(params url.Values) (UsersResp, error)
func (TwitterApi) GetFriends ¶
func (a TwitterApi) GetFriends(params url.Values) (UsersResp, error)
func (TwitterApi) GetListsOwnedBy ¶
func (a TwitterApi) GetListsOwnedBy(params url.Values) (ListsOwnershipsResp, error)
func (TwitterApi) GetMembers ¶
func (a TwitterApi) GetMembers(params url.Values) (UsersResp, error)
func (TwitterApi) GetUserTimeline ¶
func (a TwitterApi) GetUserTimeline(params url.Values) ([]*twitterpb.Tweet, error)
func (TwitterApi) LookupStatuses ¶
func (a TwitterApi) LookupStatuses(params url.Values) ([]*twitterpb.Tweet, error)
func (*TwitterApi) SetDelay ¶
func (c *TwitterApi) SetDelay(t time.Duration)
SetDelay will set the delay between throttled queries To turn of throttling, set it to 0 seconds
type TwitterError ¶
TwitterError represents a single Twitter error messages/code pair
func (TwitterError) Error ¶
func (te TwitterError) Error() string
type TwitterErrorResponse ¶
type TwitterErrorResponse struct {
Errors []TwitterError `json:"errors"`
}
TwitterErrorResponse has an array of Twitter error messages It satisfies the "error" interface For the most part, Twitter seems to return only a single error message Currently, we assume that this always contains exactly one error message
func (TwitterErrorResponse) Error ¶
func (tr TwitterErrorResponse) Error() string
func (TwitterErrorResponse) First ¶
func (tr TwitterErrorResponse) First() error