Documentation ¶
Index ¶
- Constants
- Variables
- func AuthHandler(twApp *App, handler Handler) app.Handler
- type App
- func (app *App) Authenticate(callback string) (string, error)
- func (app *App) Authorize(callback string) (string, error)
- func (a *App) Clone(ctx httpclient.Context) *App
- func (app *App) Exchange(token string, verifier string) (*Token, error)
- func (app *App) Get(token *Token, path string, data map[string]string, out interface{}) error
- func (a *App) Parse(s string) error
- func (app *App) Post(token *Token, path string, data map[string]string, out interface{}) error
- func (a *App) Stats(urls []string) (map[string]*Stats, error)
- func (app *App) Update(text string, token *Token, opts *TweetOptions) (*Tweet, error)
- func (app *App) Verify(token *Token) (*User, error)
- type Handler
- type Stats
- type Token
- type Tweet
- type TweetOptions
- type TwitterError
- type TwitterTime
- type User
Constants ¶
const ( MAX_TWEET_LENGTH = 140 URL_CONSUMED_LENGTH = 23 )
const ( REQUEST_TOKEN_URL = "https://twitter.com/oauth/request_token" ACCESS_TOKEN_URL = "https://twitter.com/oauth/access_token" AUTHORIZATION_URL = "https://twitter.com/oauth/authorize" AUTHENTICATION_URL = "https://twitter.com/oauth/authenticate" API_BASE_URL = "https://api.twitter.com/1.1/" )
Variables ¶
var (
STATUS_URL = API_BASE_URL + "statuses/update.json"
)
Functions ¶
func AuthHandler ¶
AuthHandler takes a Handler a returns a app.Handler which can be added to a app. When users are directed to this handler, they're first asked to authenticate with Twitter. If the user accepts, Handler is called with a non-nil user and a non-nil token. Otherwise, Handler is called with both parameters set to nil.
Types ¶
type App ¶
type App struct { Key string Secret string Client *httpclient.Client // contains filtered or unexported fields }
App represents a Twitter application, with its consumer key and secret. To register an application go to https://dev.twitter.com
func (*App) Parse ¶
Parse parses the app credentials from its string representation. It must have the form key:secret. If key or secret contain the ':' character you must quote them (e.g. "k:ey":"sec:ret").
type Handler ¶
Handler represents a function type which receives the result of authenticating a Twitter user.
type Token ¶
Token represents a key/secret pair for accessing Twitter services on behalf on another user.
type TweetOptions ¶
type TweetOptions struct { // If true, text will get truncated if it's longer than // the maximum tweet length (instead of returning an error). Truncate bool // Only has effect if Truncate is true. Rather than truncating // at 140 characters, it will truncate at the last whitespace. TruncateOnWhitespace bool // The ID of an existing status that the update is in reply to. // Note that Twitter ignores this unless the referenced id's // author is @mentioned in the tweet text. InReplyTo string // The latitude of the location this tweet refers to. Latitude float64 // The longitude of the location this tweet refers to. Longitude float64 // This parameter only has effect when Latitude and // Longitude are set. If this parameter is false, the // tweet will contain a pin with the exact location. Set // it to true to hide the pin. HideCoordinates bool // A place retrieved from geo/reverse_geocode PlaceId string }
TweetOptions contains some optional settings which may be specified when sending a tweet.
type TwitterError ¶
func (*TwitterError) Error ¶
func (t *TwitterError) Error() string
type TwitterTime ¶
func (*TwitterTime) UnmarshalJSON ¶
func (t *TwitterTime) UnmarshalJSON(b []byte) error
type User ¶
type User struct { Id string `json:"id_str"` ScreenName string `json:"screen_name"` Name string `json:"name"` Created TwitterTime `json:"created_at"` Favorites int `json:"favourites_count"` Followers int `json:"followers_count"` Following int `json:"following_count"` Friends int `json:"friends_count"` ImageURL string `json:"profile_image_url"` }