twitterstream

package module
v0.0.0-...-0a79e05 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2015 License: Apache-2.0 Imports: 11 Imported by: 19

README

twitterstream

GoDoc

Twitter streaming API for Go.

See twimgd.go for an example that downloads images given keywords.

License

Copyright © 2012 Daniel Huckstep. See LICENSE for details.

Documentation

Index

Constants

View Source
const (
	FilterUrl      = "https://stream.twitter.com/1.1/statuses/filter.json"
	DefaultTimeout = 1 * time.Minute
)
View Source
const DialTimeout = 5 * time.Second
View Source
const (
	TimeFormat = "Mon Jan _2 15:04:05 +0000 2006"
)

Variables

View Source
var (
	MissingCoordinates = errors.New("Missing coordinates")
)

Functions

This section is empty.

Types

type Box

type Box struct {
	Points []Point
}

func (*Box) MarshalJSON

func (b *Box) MarshalJSON() ([]byte, error)

func (*Box) UnmarshalJSON

func (b *Box) UnmarshalJSON(data []byte) (err error)

type Client

type Client struct {
	Oauth       *oauth.Client
	Credentials *oauth.Credentials
	Timeout     time.Duration
}

func NewClient

func NewClient(consumerKey, consumerSecret, accessToken, accessSecret string) *Client

func NewClientTimeout

func NewClientTimeout(consumerKey, consumerSecret, accessToken, accessSecret string, timeout time.Duration) *Client

func (*Client) Filter

func (c *Client) Filter(form url.Values) (*Connection, error)

func (*Client) Follow

func (c *Client) Follow(userIds ...string) (*Connection, error)

func (*Client) Language

func (c *Client) Language(language string) (*Connection, error)

func (*Client) Locations

func (c *Client) Locations(p1 Point, p2 Point) (*Connection, error)

func (*Client) Sample

func (c *Client) Sample() (*Connection, error)

func (*Client) Track

func (c *Client) Track(keywords ...string) (*Connection, error)

type Connection

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

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) Next

func (c *Connection) Next() (*Tweet, error)

type Contributor

type Contributor struct {
	Id         int64  `json:"id"`
	IdString   string `json:"id_str"`
	ScreenName string `json:"screen_name"`
}

type Entities

type Entities struct {
	Hashtags []Hashtag `json:"hashtags"`
	Media    []Medium  `json:"media"`
	Mentions []Mention `json:"user_mentions"`
	Urls     []Url     `json:"urls"`
}

type Hashtag

type Hashtag struct {
	Text    string    `json:"text"`
	Indices IndexPair `json:"indices"`
}

type IndexPair

type IndexPair struct {
	Start int
	End   int
}

func (IndexPair) MarshalJSON

func (i IndexPair) MarshalJSON() ([]byte, error)

func (*IndexPair) UnmarshalJSON

func (i *IndexPair) UnmarshalJSON(data []byte) error

type Latitude

type Latitude float64

func (Latitude) Float64

func (l Latitude) Float64() float64

type Longitude

type Longitude float64

func (Longitude) Float64

func (l Longitude) Float64() float64

type Medium

type Medium struct {
	Id             int64     `json:"id"`
	IdStr          string    `json:"id_str"`
	Type           string    `json:"type"`
	MediaUrl       string    `json:"media_url"`
	SecureMediaUrl string    `json:"media_url_https"`
	Url            string    `json:"url"`
	DisplayUrl     string    `json:"display_url"`
	ExpandedUrl    *string   `json:"expanded_url"`
	Sizes          Sizes     `json:"sizes"`
	Indices        IndexPair `json:"indices"`
}

type Mention

type Mention struct {
	Id         int64     `json:"id"`
	IdStr      string    `json:"id_str"`
	ScreenName string    `json:"screen_name"`
	FullName   string    `json:"full_name"`
	Indices    IndexPair `json:"indices"`
}

type Place

type Place struct {
	// Contains a hash of variant information about the place.
	Attributes map[string]interface{} `json:"attributes"`

	// A bounding box of coordinates which encloses this place.
	BoundingBox Box `json:"bounding_box"`

	// Name of the country containing this place.
	Country string `json:"country"`

	// Shortened country code representing the country containing this place.
	CountryCode string `json:"country_code"`

	// Full human-readable representation of the place's name.
	FullName string `json:"full_name"`

	// ID representing this place. Note that this is represented as a string, not an integer.
	Id string `json:"id"`

	// Short human-readable representation of the place's name.
	Name string `json:"name"`

	// The type of location represented by this place.
	Type string `json:"place_type"`

	// URL representing the location of additional place metadata for this place.
	Url string `json:"url"`
}

type Point

type Point struct {
	Lat  Latitude
	Long Longitude
}

func (*Point) MarshalJSON

func (c *Point) MarshalJSON() ([]byte, error)

func (*Point) UnmarshalJSON

func (c *Point) UnmarshalJSON(data []byte) error

type Size

type Size struct {
	Width  int    `json:"w"`
	Height int    `json:"h"`
	Resize string `json:"resize"`
}

type Sizes

type Sizes struct {
	Large  Size `json:"large"`
	Medium Size `json:"medium"`
	Small  Size `json:"small"`
	Thumb  Size `json:"thumb"`
}

type Time

type Time struct {
	time.Time
}

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

type Tweet

type Tweet struct {
	// The integer representation of the unique identifier for this Tweet. This number is greater than 53 bits and some programming languages may have difficulty/silent defects in interpreting it. Using a signed 64 bit integer for storing this identifier is safe. Use id_str for fetching the identifier to stay on the safe side. See Twitter IDs, JSON and Snowflake.
	Id int64 `json:"id"`

	// The string representation of the unique identifier for this Tweet. Implementations should use this rather than the large integer in id.
	IdString string `json:"id_str"`

	// An collection of brief user objects (usually only one) indicating users who contributed to the authorship of the tweet, on behalf of the official tweet author.
	Contributors []Contributor `json:"contributors"`

	// Represents the geographic location of this Tweet as reported by the user or client application.
	Coordinates *Point `json:"coordinates"`

	// Time when this Tweet was created.
	CreatedAt Time `json:"created_at"`

	// Entities which have been parsed out of the text of the Tweet.
	Entities Entities `json:"entities"`

	// Perspectival. Indicates whether this Tweet has been favorited by the authenticating user.
	Favorited *bool `json:"favorited"`

	// If the represented Tweet is a reply, this field will contain the screen name of the original Tweet's author.
	InReplyToScreenName *string `json:"in_reply_to_screen_name"`

	// If the represented Tweet is a reply, this field will contain the integer representation of the original Tweet's ID.
	InReplyToStatusId *int64 `json:"in_reply_to_status_id"`

	// If the represented Tweet is a reply, this field will contain the string representation of the original Tweet's ID.
	InReplyToStatusIdStr *string `json:"in_reply_to_status_id_str"`

	// If the represented Tweet is a reply, this field will contain the integer representation of the original Tweet's author ID.
	InReplyToUserId *int64 `json:"in_reply_to_user_id"`

	// If the represented Tweet is a reply, this field will contain the string representation of the original Tweet's author ID.
	InReplyToUserIdStr *string `json:"in_reply_to_user_id_str"`

	// When present, indicates a BCP 47 language identifier corresponding to the machine-detected language of the Tweet text, or “und” if no language could be detected.
	Lang string `json:"lang"`

	// When present, indicates that the tweet is associated (but not necessarily originating from) a Place.
	Place *Place `json:"place"`

	// This field only surfaces when a tweet contains a link. The meaning of the field doesn't pertain to the tweet content itself, but instead it is an indicator that the URL contained in the tweet may contain content or media identified as sensitive content.
	PossiblySensitive *bool `json:"possibly_sensitive"`

	// Number of times this Tweet has been retweeted. This field is no longer capped at 99 and will not turn into a String for "100+"
	RetweetCount int `json:"retweet_count"`

	// Perspectival. Indicates whether this Tweet has been retweeted by the authenticating user.
	Retweeted bool `json:"retweeted"`

	// If Retweet the original Tweet can be found here.
	RetweetedStatus *Tweet `json:"retweeted_status"`

	// Utility used to post the Tweet, as an HTML-formatted string. Tweets from the Twitter website have a source value of web.
	Source string `json:"source"`

	// The actual UTF-8 text of the status update.
	Text string `json:"text"`

	// Indicates whether the value of the text parameter was truncated, for example, as a result of a retweet exceeding the 140 character Tweet length. Truncated text will end in ellipsis, like this ...
	Truncated bool `json:"truncated"`

	// When present, indicates a textual representation of the two-letter country codes this content is withheld from. See New Withheld Content Fields in API Responses.
	WithheldInCountries string `json:"withheld_in_countries"`

	// When present, indicates whether the content being withheld is the "status" or a "user." See New Withheld Content Fields in API Responses.
	WithheldScope string `json:"withheld_scope"`

	// The user who posted this Tweet.
	User User `json:"user"`
}

type Url

type Url struct {
	Url         string    `json:"url"`
	DisplayUrl  string    `json:"display_url"`
	ExpandedUrl *string   `json:"expanded_url"`
	Indices     IndexPair `json:"indices"`
}

type User

type User struct {
	// Indicates that the user has an account with "contributor mode" enabled, allowing for Tweets issued by the user to be co-authored by another account. Rarely true.
	ContributorsEnabled bool `json:"contributors_enabled"`

	// The UTC datetime that the user account was created on Twitter.
	CreatedAt Time `json:"created_at"`

	// When true, indicates that the user has not altered the theme or background of their user profile.
	DefaultProfile bool `json:"default_profile"`

	// When true, indicates that the user has not uploaded their own avatar and a default egg avatar is used instead.
	DefaultProfileImage bool `json:"default_profile_image"`

	// The user-defined UTF-8 string describing their account.
	Description *string `json:"description"`

	// The number of tweets this user has favorited in the account's lifetime. British spelling used in the field name for historical reasons.
	FavouritesCount int `json:"favourites_count"`

	// Perspectival. When true, indicates that the authenticating user has issued a follow request to this protected user account.
	FollowRequestSent *bool `json:"follow_request_sent"`

	// Perspectival. Deprecated. When true, indicates that the authenticating user is following this user. Some false negatives are possible when set to "false," but these false negatives are increasingly being represented as "null" instead. See Discussion.
	Following *bool `json:"following"`

	// The number of followers this account currently has. Under certain conditions of duress, this field will temporarily indicate "0."
	FollowersCount int `json:"followers_count"`

	// The number of users this account is following (AKA their "followings"). Under certain conditions of duress, this field will temporarily indicate "0."
	FriendsCount int `json:"friends_count"`

	// When true, indicates that the user has enabled the possibility of geotagging their Tweets. This field must be true for the current user to attach geographic data when using POST statuses/update.
	GeoEnabled bool `json:"geo_enabled"`

	// The integer representation of the unique identifier for this User. This number is greater than 53 bits and some programming languages may have difficulty/silent defects in interpreting it. Using a signed 64 bit integer for storing this identifier is safe. Use id_str for fetching the identifier to stay on the safe side.
	Id int64 `json:"id"`

	// The string representation of the unique identifier for this Tweet. Implementations should use this rather than the large integer in id.
	IdStr string `json:"id_str"`

	// When true, indicates that the user is a participant in Twitter's translator community.
	IsTranslator bool `json:"is_translator"`

	// The ISO 639-1 two-letter character code for the user's self-declared user interface language. May or may not have anything to do with the content of their Tweets.
	Language string `json:"lang"`

	// The number of public lists that this user is a member of.
	ListedCount int `json:"listed_count"`

	// The user-defined location for this account's profile. Not necessarily a location nor parseable. This field will occasionally be fuzzily interpreted by the Search service.
	Location *string `json:"location"`

	// The name of the user, as they've defined it. Not necessarily a person's name. Typically capped at 20 characters, but subject to change.
	Name string `json:"name"`

	// The hexadecimal color chosen by the user for their background.
	ProfileBackgroundColor *string `json:"profile_background_color"`

	// A HTTP-based URL pointing to the background image the user has uploaded for their profile.
	ProfileBackgroundImageUrl *string `json:"profile_background_image_url"`

	// A HTTPS-based URL pointing to the background image the user has uploaded for their profile.
	ProfileBackgroundImageUrlHttps *string `json:"profile_background_image_url_https"`

	// When true, indicates that the user's profile_background_image_url should be tiled when displayed.
	ProfileBackgroundTile bool `json:"profile_background_tile"`

	// A HTTP-based URL pointing to the user's avatar image.
	ProfileImageUrl string `json:"profile_image_url"`

	// A HTTPS-based URL pointing to the user's avatar image.
	ProfileImageUrlHttps string `json:"profile_image_url_https"`

	// The hexadecimal color the user has chosen to display links with in their Twitter UI.
	ProfileLinkColor string `json:"profile_link_color"`

	// The hexadecimal color the user has chosen to display sidebar borders with in their Twitter UI.
	ProfileSidebarBorderColor string `json:"profile_sidebar_border_color"`

	// The hexadecimal color the user has chosen to display sidebar backgrounds with in their Twitter UI.
	ProfileSidebarFillColor string `json:"profile_sidebar_fill_color"`

	// The hexadecimal color the user has chosen to display text with in their Twitter UI.
	ProfileTextColor string `json:"profile_text_color"`

	// When true, indicates the user wants their uploaded background image to be used.
	ProfileUseBackgroundImage bool `json:"profile_use_background_image"`

	// When true, indicates that this user has chosen to protect their Tweets.
	Protected bool `json:"protected"`

	// The screen name, handle, or alias that this user identifies themselves with. screen_names are unique but subject to change. Use id_str as a user identifier whenever possible. Typically a maximum of 15 characters long, but some historical accounts may exist with longer names.
	ScreenName string `json:"screen_name"`

	// Indicates that the user would like to see media inline.
	ShowAllInlineMedia bool `json:"show_all_inline_media"`

	// If possible, the user's most recent tweet or retweet. In some circumstances, this data cannot be provided and this field will be omitted, null, or empty. Perspectival attributes within tweets embedded within users cannot always be relied upon.
	Status *Tweet `json:"status"`

	// The number of tweets (including retweets) issued by the user.
	StatusesCount int `json:"statuses_count"`

	// A string describing the Time Zone this user declares themselves within.
	TimeZone *string `json:"time_zone"`

	// A URL provided by the user in association with their profile.
	Url *string `json:"url"`

	// The offset from GMT/UTC in seconds.
	UtcOffset *int `json:"utc_offset"`

	// When true, indicates that the user has a verified account.
	Verified bool `json:"verified"`

	// When present, indicates a textual representation of the two-letter country codes this user is withheld from.
	WithheldInCountries string `json:"withheld_in_countries"`

	// When present, indicates whether the content being withheld is the "status" or a "user." See New Withheld Content Fields in API Responses.
	WithheldScope string `json:"withheld_scope"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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