tumblr

package module
v0.0.0-...-2b5115b Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2014 License: MIT Imports: 10 Imported by: 1

README

tumblr-go

Tumblr client for the Go programming language

TODO

  • /posts/*, /user/* - I don't have a need for these but adding them is straightforward.
  • OpenID - Only strictly required for the above.
  • Use this instead of my butt-ugly query string construction: github.com/google/go-querystring/query

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APICredentials

type APICredentials struct {
	Key    string
	Secret string
}

type AltSizeData

type AltSizeData struct {
	Width  int
	Height int
	URL    string
}

One alternate size of a Photo

type AnswerPost

type AnswerPost struct {
	PostBase
	AskingName string
	AskingURL  string
	Question   string
	Answer     string
}

Answer post

type AudioPost

type AudioPost struct {
	PostBase
	Caption     string
	Player      string
	Plays       int64
	AlbumArt    string
	Artist      string
	Album       string
	TrackName   string
	TrackNumber int64
	Year        int
}

Audio post

type Blog

type Blog struct {
	BaseHostname string
	// contains filtered or unexported fields
}

func (*Blog) Avatar

func (blog *Blog) Avatar(size int32) (*url.URL, error)

func (Blog) Followers

func (blog Blog) Followers(params LimitOffset) ([]Blog, error)

Blog followers

func (Blog) Info

func (blog Blog) Info() (*BlogInfo, error)

Blog Info

func (*Blog) Likes

func (blog *Blog) Likes(params LimitOffset) (*BlogLikes, error)

Posts liked by a blog

func (*Blog) Posts

func (blog *Blog) Posts(params PostRequestParams) (*PostCollection, error)

Posts posted by a blog

type BlogFollowers

type BlogFollowers struct {
	TotalUsers int64
	Users      []FollowingUser
}

type BlogInfo

type BlogInfo struct {
	Title       string
	Posts       int64
	Name        string
	Updated     int64
	Description string
	Ask         bool
	AskAnon     bool
	Likes       int64
}

Type returned by blog.Info()

type BlogLikes

type BlogLikes struct {
	Likes      *PostCollection
	TotalCount int64
}

type ChatPost

type ChatPost struct {
	PostBase
	Title    string
	Body     string
	Dialogue []DialogueData
}

Chat post

type DialogueData

type DialogueData struct {
	Name   string
	Label  string
	Phrase string
}

One component of a conversation in a Dialogue in a Chat

type EmbedObjectData

type EmbedObjectData struct {
	Width     int
	EmbedCode string
}

One embedded video player in a VideoPost

type FollowingUser

type FollowingUser struct {
	User
	Following bool // Is the following reciprocal?
}

type LimitOffset

type LimitOffset struct {
	Limit  int
	Offset int
}

type LinkPost

type LinkPost struct {
	PostBase
	Title       string
	URL         string
	Description string
}

Link post

type Meta

type Meta struct {
	Status int64
	Msg    string
}

type NoteData

type NoteData struct {
	Timestamp interface{} // this is either a string or an integer :(
	BlogName  string      `json:"blog_name"`
	BlogURL   string      `json:"blog_url"`
	PostID    string      `json:"post_id"` // wtf
	Type      string      `json:"type"`    // reblog, like, post, ...?
}

General notes information

{
	  "timestamp": "1401041794", // or an integer! lol
	  "blog_name": "nalisification",
	  "blog_url": "http://nalisification.tumblr.com/",
	  "post_id": "1234",
	  "type": "reblog"
},

type PhotoData

type PhotoData struct {
	Caption  string // photosets only
	AltSizes []AltSizeData
}

One photo in a PhotoPost

type PhotoPost

type PhotoPost struct {
	PostBase
	Photos  []PhotoData
	Caption string
	Width   int64
	Height  int64
}

Photo post

type Post

type Post interface {
	PostBlogName() string
	PostId() int64
	PostPostURL() string
	PostTimestamp() int64
	PostType() PostType
	PostDate() string
	PostFormat() string
	PostReblogKey() string
	PostTags() []string
	PostBookmarklet() bool
	PostMobile() bool
	PostSourceURL() string
	PostSourceTitle() string
	PostLiked() bool
	PostState() string // published, ueued, draft, private
	PostNotes() []NoteData
	PostTotalPosts() int64 // total posts in result set for pagination
}

Accessors for the common fields of a Post

type PostBase

type PostBase struct {
	BlogName    string
	Id          int64
	PostURL     string
	Type        string
	Timestamp   int64
	Date        string
	Format      string
	ReblogKey   string
	Tags        []string
	Bookmarklet bool
	Mobile      bool
	SourceURL   string
	SourceTitle string
	Liked       bool
	State       string // published, ueued, draft, private
	Notes       []NoteData
	TotalPosts  int64 // total posts in result set for pagination
}

Stuff in the "response":"posts" field

func (*PostBase) PostBlogName

func (p *PostBase) PostBlogName() string

func (*PostBase) PostBookmarklet

func (p *PostBase) PostBookmarklet() bool

func (*PostBase) PostDate

func (p *PostBase) PostDate() string

func (*PostBase) PostFormat

func (p *PostBase) PostFormat() string

func (*PostBase) PostId

func (p *PostBase) PostId() int64

func (*PostBase) PostLiked

func (p *PostBase) PostLiked() bool

func (*PostBase) PostMobile

func (p *PostBase) PostMobile() bool

func (*PostBase) PostNotes

func (p *PostBase) PostNotes() []NoteData

func (*PostBase) PostPostURL

func (p *PostBase) PostPostURL() string

func (*PostBase) PostReblogKey

func (p *PostBase) PostReblogKey() string

func (*PostBase) PostSourceTitle

func (p *PostBase) PostSourceTitle() string

func (*PostBase) PostSourceURL

func (p *PostBase) PostSourceURL() string

func (*PostBase) PostState

func (p *PostBase) PostState() string

func (*PostBase) PostTags

func (p *PostBase) PostTags() []string

func (*PostBase) PostTimestamp

func (p *PostBase) PostTimestamp() int64

func (*PostBase) PostTotalPosts

func (p *PostBase) PostTotalPosts() int64

func (*PostBase) PostType

func (p *PostBase) PostType() PostType

type PostCollection

type PostCollection struct {
	Posts       []Post // A conjunction of the below
	TextPosts   []TextPost
	QuotePosts  []QuotePost
	LinkPosts   []LinkPost
	AnswerPosts []AnswerPost
	VideoPosts  []VideoPost
	AudioPosts  []AudioPost
	PhotoPosts  []PhotoPost
	ChatPosts   []ChatPost
}

func NewPostCollection

func NewPostCollection(r *json.RawMessage) (*PostCollection, error)

Constructs a PostCollection of typed Posts given the json.RawMessage of "response":"posts" which must be an array

type PostRequestParams

type PostRequestParams struct {
	PostType   string `url:"-"`
	Id         int64  `url:"id,omitempty"`
	Tag        string `url:"tag,omitempty"`
	ReblogInfo bool   `url:"reblog_info,omitempty"`
	NotesInfo  bool   `url:"notes_info,omitempty"`
	Filter     string `url:"filter,omitempty"`
	LimitOffset
}

Search criteria to be passed to the Posts method

type PostType

type PostType int

Post Types

const (
	Unknown PostType = iota
	Text
	Quote
	Link
	Answer
	Video
	Audio
	Photo
	Chat
)

func TypeOfPost

func TypeOfPost(t string) PostType

Return the PostType of the type described in the JSON

type QuotePost

type QuotePost struct {
	PostBase
	Text   string
	Source string
}

Quote post

type TextPost

type TextPost struct {
	PostBase
	Title string
	Body  string
}

Text post

type Tumblr

type Tumblr struct {
	Credentials APICredentials
}

func (Tumblr) NewBlog

func (t Tumblr) NewBlog(baseHostname string) Blog

Creates a new Blog object given either the proper base hostname or a URL containing the base hostname

type TumblrAPIResponse

type TumblrAPIResponse struct {
	Meta     Meta
	Response *json.RawMessage
}

type TumblrError

type TumblrError struct {
	Message string
}

Errors

func (TumblrError) Error

func (err TumblrError) Error() string

type User

type User struct {
}

type VideoPost

type VideoPost struct {
	PostBase
	Caption string
	Players []EmbedObjectData
}

Video post - TODO Handle all the different sources - not documented :(

Jump to

Keyboard shortcuts

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