stream

package module
v0.0.0-...-e4a984b Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2015 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package stream provides methods for listening to Twitter's Streaming APIs.

To begin using you will need credentials for an app setup in Twitter. Then you can get your timeline like so,

// assuming consumerKey, consumerSecret, accessToken and accessSecret hold
// the credentials
auth := stream.Auth(consumerKey, consumerSecret, accessToken, accessSecret)

for tweet := range.Timeline(auth) {
  log.Println(tweet)
}

Warning, this library does not do any error handling at the moment, it ignores any incoming messages that do not look like tweets.

Index

Constants

View Source
const (
	SAMPLE_URL = "https://stream.twitter.com/1.1/statuses/sample.json"
	STREAM_URL = "https://userstream.twitter.com/1.1/user.json"
	USER_URL   = STREAM_URL + "?with=user"

	DETAILS_URL = "https://api.twitter.com/1.1/account/verify_credentials.json"
)
View Source
const (
	DIAL_TIMEOUT = 5 * time.Second
)
View Source
const (
	TimeFormat = "Mon Jan _2 15:04:05 +0000 2006"
)

Variables

This section is empty.

Functions

func Auth

func Auth(consumerKey, consumerSecret, accessToken, accessSecret string) *auth

Types

type Entities

type Entities struct {
	Urls []Url `json:"urls"`
}

type Stream

type Stream chan Tweet

func Self

func Self(creds *auth) Stream

func Timeline

func Timeline(creds *auth) Stream

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 {
	Id        int64    `json:"id"`
	Source    string   `json:"source"`
	CreatedAt Time     `json:"created_at"`
	Entities  Entities `json:"entities"`
	Text      string   `json:"text"`
	User      User     `json:"user"`
}
func (t Tweet) Link() string

type Url

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

type User

type User struct {
	Id         int64   `json:"id"`
	Name       string  `json:"name"`
	ScreenName string  `json:"screen_name"`
	Url        *string `json:"url"`
}

Jump to

Keyboard shortcuts

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