Documentation ¶
Overview ¶
Implements a Twitter client library in Go.
Index ¶
- Constants
- type APIResponse
- func (r APIResponse) HasMediaRateLimit() bool
- func (r APIResponse) HasRateLimit() bool
- func (r APIResponse) MediaRateLimit() uint32
- func (r APIResponse) MediaRateLimitRemaining() uint32
- func (r APIResponse) MediaRateLimitReset() time.Time
- func (r APIResponse) Parse(out interface{}) (err error)
- func (r APIResponse) RateLimit() uint32
- func (r APIResponse) RateLimitRemaining() uint32
- func (r APIResponse) RateLimitReset() time.Time
- func (r APIResponse) ReadBody() string
- type BearerToken
- type Client
- func (c *Client) FetchAppToken() (err error)
- func (c *Client) GetAppToken() string
- func (c *Client) SendRequest(req *http.Request) (resp *APIResponse, err error)
- func (c *Client) SetAppToken(token string)
- func (c *Client) SetUser(user *oauth1a.UserConfig)
- func (c *Client) Sign(req *http.Request) (err error)
- type CursoredLists
- type Entities
- type Error
- type Errors
- type List
- type Lists
- type RateLimitError
- type RetweetedStatus
- type SearchResults
- type Timeline
- type Tweet
- type Url
- type User
Constants ¶
const ( H_LIMIT = "X-Rate-Limit-Limit" H_LIMIT_REMAIN = "X-Rate-Limit-Remaining" H_LIMIT_RESET = "X-Rate-Limit-Reset" H_MEDIA_LIMIT = "X-MediaRateLimit-Limit" H_MEDIA_LIMIT_REMAIN = "X-MediaRateLimit-Remaining" H_MEDIA_LIMIT_RESET = "X-MediaRateLimit-Reset" )
const ( STATUS_OK = 200 STATUS_INVALID = 400 STATUS_UNAUTHORIZED = 401 STATUS_FORBIDDEN = 403 STATUS_NOTFOUND = 404 STATUS_LIMIT = 429 STATUS_GATEWAY = 502 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
func (APIResponse) HasMediaRateLimit ¶
func (r APIResponse) HasMediaRateLimit() bool
func (APIResponse) HasRateLimit ¶
func (r APIResponse) HasRateLimit() bool
func (APIResponse) MediaRateLimit ¶
func (r APIResponse) MediaRateLimit() uint32
func (APIResponse) MediaRateLimitRemaining ¶
func (r APIResponse) MediaRateLimitRemaining() uint32
func (APIResponse) MediaRateLimitReset ¶
func (r APIResponse) MediaRateLimitReset() time.Time
func (APIResponse) Parse ¶
func (r APIResponse) Parse(out interface{}) (err error)
Parses a JSON encoded HTTP response into the supplied interface.
func (APIResponse) RateLimit ¶
func (r APIResponse) RateLimit() uint32
func (APIResponse) RateLimitRemaining ¶
func (r APIResponse) RateLimitRemaining() uint32
func (APIResponse) RateLimitReset ¶
func (r APIResponse) RateLimitReset() time.Time
func (APIResponse) ReadBody ¶
func (r APIResponse) ReadBody() string
type BearerToken ¶
type BearerToken struct {
AccessToken string
}
type Client ¶
type Client struct { Host string OAuth *oauth1a.Service User *oauth1a.UserConfig AppToken *BearerToken HttpClient *http.Client }
Implements a Twitter client.
func NewClient ¶
func NewClient(config *oauth1a.ClientConfig, user *oauth1a.UserConfig, host string) *Client
Creates a new Twitter client with the supplied OAuth configuration. Supports the use of HTTP proxies through the $HTTP_PROXY env var. For example:
export HTTP_PROXY=http://localhost:8888
When using a proxy, disable TLS certificate verification with the following:
export TLS_INSECURE=1
func (*Client) FetchAppToken ¶
Requests a new app auth bearer token and stores it.
func (*Client) GetAppToken ¶
Returns the current app-only auth token or an empty string. Must call FetchAppToken to populate this value before getting it. You may call SetAppToken with the value returned by this call in order to restore a previously-fetched bearer token to use.
func (*Client) SendRequest ¶
func (c *Client) SendRequest(req *http.Request) (resp *APIResponse, err error)
Sends a HTTP request through this instance's HTTP client.
func (*Client) SetAppToken ¶
Sets the app-only auth token to the specified string.
func (*Client) SetUser ¶
func (c *Client) SetUser(user *oauth1a.UserConfig)
Changes the user authorization credentials for this client.
type CursoredLists ¶
type CursoredLists map[string]interface{}
func (CursoredLists) Lists ¶
func (cl CursoredLists) Lists() Lists
func (CursoredLists) NextCursorStr ¶
func (cl CursoredLists) NextCursorStr() string
func (CursoredLists) PreviousCursorStr ¶
func (cl CursoredLists) PreviousCursorStr() string
type List ¶
type List map[string]interface{}
A List!
func (List) MemberCount ¶
func (List) SubscriberCount ¶
type RateLimitError ¶
func (RateLimitError) Error ¶
func (e RateLimitError) Error() string
type RetweetedStatus ¶
type RetweetedStatus map[string]interface{}
It's a retweet status!
func (RetweetedStatus) CreatedAt ¶
func (rs RetweetedStatus) CreatedAt() (out time.Time)
func (RetweetedStatus) FavoriteCount ¶
func (rs RetweetedStatus) FavoriteCount() int64
func (RetweetedStatus) IdStr ¶
func (rs RetweetedStatus) IdStr() string
func (RetweetedStatus) RetweetCount ¶
func (rs RetweetedStatus) RetweetCount() int64
func (RetweetedStatus) Text ¶
func (rs RetweetedStatus) Text() string
type SearchResults ¶
type SearchResults map[string]interface{}
It's a structured list of Tweets!
func (SearchResults) SearchMetadata ¶
func (sr SearchResults) SearchMetadata() map[string]interface{}
func (SearchResults) Statuses ¶
func (sr SearchResults) Statuses() []Tweet
type Tweet ¶
type Tweet map[string]interface{}
It's a Tweet! (Adorably referred to by the API as a "status").
func (Tweet) RetweetedStatus ¶
func (t Tweet) RetweetedStatus() RetweetedStatus