twittbid

package
v0.0.0-...-46032ff Latest Latest
Warning

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

Go to latest
Published: May 30, 2015 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//BaseURL for twitter cfg
	BaseURL = "https://api.twitter.com/1.1"
)

Variables

View Source
var OauthClient = oauth.Client{
	TemporaryCredentialRequestURI: "https://api.twitter.com/oauth/request_token",
	ResourceOwnerAuthorizationURI: "https://api.twitter.com/oauth/authenticate",
	TokenRequestURI:               "https://api.twitter.com/oauth/access_token",
}

OauthClient defines oauth URLs

Functions

func CleanValues

func CleanValues(v url.Values) url.Values

CleanValues method

func DecodeResponse

func DecodeResponse(resp *http.Response, data interface{}) error

DecodeResponse decode http response

func SetConsumerKey

func SetConsumerKey(consumerKey string)

SetConsumerKey this your API key

func SetConsumerSecret

func SetConsumerSecret(consumerSecret string)

SetConsumerSecret from your API secret

Types

type APIError

type APIError struct {
	StatusCode int
	Header     http.Header
	Body       string
	Decoded    TwitterErrorResponse
	URL        *url.URL
}

APIError struct

func (*APIError) CheckRateLimit

func (aerr *APIError) CheckRateLimit() (isRateLimitError bool, nextWindow time.Time)

CheckRateLimit validate response for if status code 429 or 130

func (APIError) Error

func (aerr APIError) Error() string

Error the error interface

type Contributor

type Contributor struct {
	ID         int64  `json:"id"`
	IDStr      string `json:"id_str"`
	ScreenName string `json:"screen_name"`
}

Contributor define the twitter contributor details

type Coordinates

type Coordinates struct {
	Coordinates [2]float64 `json:"coordinates"` // Coordinate always has to have exactly 2 values
	Type        string     `json:"type"`
}

Coordinates define geo location

type Entities

type Entities struct {
	Hashtags []struct {
		Indices []int
		Text    string
	}
	Urls []struct {
		Indices     []int
		URL         string
		DisplayURL  string
		ExpandedURL string
	}
	URL          URLEntity
	UserMentions []struct {
		Name       string
		Indices    []int
		ScreenName string
		ID         int64
		IDstr      string
	}
	Media []struct {
		ID            int64
		IDstr         string
		MediaURL      string
		MediaURLhttps string
		URL           string
		DisplayURL    string
		ExpandedURL   string
		Sizes         MediaSizes
		Type          string
		Indices       []int
	}
}

Entities defines the entities object

type MediaSize

type MediaSize struct {
	W      int
	H      int
	Resize string
}

MediaSize defines media object

type MediaSizes

type MediaSizes struct {
	Medium MediaSize
	Thumb  MediaSize
	Small  MediaSize
	Large  MediaSize
}

MediaSizes defines the sizes for media object

type Query

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

Query struct

type Response

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

Response struct

type SearchMetadata

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

SearchMetadata defines search metadata object

type SearchResponse

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

SearchResponse defines the search response object with the twitter list and related metadata

func Search(hashtag string) (SearchResponse, error)

Search is for handle twitter search

type Tweet

type Tweet struct {
	Contributors         []Contributor          `json:"contributors"` // Not yet generally available to all, so hard to test
	Coordinates          *Coordinates           `json:"coordinates"`
	CreatedAt            string                 `json:"created_at"`
	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"`
	Truncated            bool                   `json:"truncated"`
	User                 User                   `json:"user"`
	WithheldCopyright    bool                   `json:"withheld_copyright"`
	WithheldInCountries  []string               `json:"withheld_in_countries"`
	WithheldScope        string                 `json:"withheld_scope"`
}

Tweet defines the twitt itself to enable transform from a json representation

type TwitterAPI

type TwitterAPI struct {
	Credentials *oauth.Credentials

	HTTPClient *http.Client
	// contains filtered or unexported fields
}

TwitterAPI defines the twitter API fields eg: credentials, etc.

func (TwitterAPI) Get

func (t TwitterAPI) Get(urlStr string, form url.Values, data interface{}) error

Get http method

func (TwitterAPI) Post

func (t TwitterAPI) Post(urlStr string, form url.Values, data interface{}) error

Post http method

type TwitterError

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

TwitterError json struct

type TwitterErrorResponse

type TwitterErrorResponse struct {
	Errors []TwitterError `json:"errors"`
}

TwitterErrorResponse json struct

type URLEntity

type URLEntity struct {
	Urls []struct {
		Indices     []int
		URL         string
		DisplayURL  string
		ExpandedURL string
	}
}

URLEntity defines the url object

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"`
	Entities                       Entities `json:"entities"`
	FavouritesCount                int      `json:"favourites_count"`
	FollowRequestSent              bool     `json:"follow_request_sent"`
	FollowersCount                 int      `json:"followers_count"`
	Following                      bool     `json:"following"`
	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"` // BCP-47 code of user defined language
	ListedCount                    int64    `json:"listed_count"`
	Location                       string   `json:"location"` // User defined 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"` // Only included if the user is a friend
	StatusesCount                  int64    `json:"statuses_count"`
	TimeZone                       string   `json:"time_zone"`
	URL                            string   `json:"url"` // From UTC in seconds
	UtcOffset                      int      `json:"utc_offset"`
	Verified                       bool     `json:"verified"`
	WithheldInCountries            string   `json:"withheld_in_countries"`
	WithheldScope                  string   `json:"withheld_scope"`
}

User define the twitter author user details

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL