go-tumblr: github.com/benfb/go-tumblr/tumblr Index | Examples | Files

package tumblr

import "github.com/benfb/go-tumblr/tumblr"

Package tumblr provides a wrapper for interacting with the tumblr API

Index

Examples

Package Files

config.go helpers.go request.go response.go tumblr.go types.go

func Authorize Uses

func Authorize(cK, cS string) (oauth1.Token, oauth1.Config)

Authorize gets an API token for the user

Code:

consumerKey := tumblr.GetConsumerKey()
consumerSecret := tumblr.GetConsumerSecret()
fmt.Println(tumblr.Authorize(consumerKey, consumerSecret))

Output:

{ns2bLkD57SOGw3ak2oMemNmEkRazSPXydOV309Gff0ibv2Mwdg mPhaIes9R5GmweVDl2IwLvjkrNUmV2S6at695Ll892PTVjiie}

func Configure Uses

func Configure(name, path string)

Configure sets configuration variables from config.json

func Contains Uses

func Contains(s []string, e string) bool

Contains checks to see if element e exists in slice s

func GetConsumerKey Uses

func GetConsumerKey() string

GetConsumerKey accesses consumerKey in the config file

func GetConsumerSecret Uses

func GetConsumerSecret() string

GetConsumerSecret accesses consumerSecret in the config file

func GetHost Uses

func GetHost() string

GetHost accesses host in the config file

func GetToken Uses

func GetToken() string

GetToken accesses token in the config file

func GetTokenSecret Uses

func GetTokenSecret() string

GetTokenSecret accesses tokenSecret in the config file

func PostValidOptions Uses

func PostValidOptions(postType string) []string

PostValidOptions defines which parameters are valid for /post, /post/edit, and /post/reblog.

func ValidateBlogName Uses

func ValidateBlogName(blogName string) string

ValidateBlogName validate the blogName and let you pass in a blogname like client.blogInfo("codingjester") or client.blogInfo("codingjester.tumblr.com") or client.blogInfo("blog.johnbunting.me") and query all the same blog.

Code:

fmt.Println(tumblr.ValidateBlogName("staff"))

Output:

"staff.tumblr.com"

func ValidateParams Uses

func ValidateParams(params map[string]string, validParams []string) map[string]string

ValidateParams validates the parameters for API requests

Code:

params := map[string]string{"limit": "1", "offset": "1", "cat": "no"}
validParams := []string{"limit", "offset"}
fmt.Println(tumblr.ValidateParams(params, validParams))

Output:

{"limit:" "1", "offset": "1"}

type AnswerPost Uses

type AnswerPost struct {
    Post
    // contains filtered or unexported fields
}

AnswerPost represents a Post of type "answer"

type AudioPost Uses

type AudioPost struct {
    Post
    // contains filtered or unexported fields
}

AudioPost represents a post of type "audio"

type Blog Uses

type Blog struct {
    Title                string  `json:"title"`
    Posts                float64 `json:"posts"`
    Name                 string  `json:"name"`
    Updated              float64 `json:"updated"`
    Description          string  `json:"description"`
    Ask                  bool    `json:"ask"`
    AskAnon              bool    `json:"ask_anon"`
    Likes                float64 `json:"likes"`
    IsBlockedFromPrimary bool    `json:"is_blocked_from_primary"`
}

Blog represents an individual Tumbelog

type BlogAvatarResponse Uses

type BlogAvatarResponse struct {
    Meta     `json:"meta"`
    Response struct {
        AvatarURL string `json:"avatar_url"`
    }   `json:"response,omitempty"`
}

BlogAvatarResponse is a response from /avatar

type BlogFollowersResponse Uses

type BlogFollowersResponse struct {
    Meta     `json:"meta"`
    Response struct {
        TotalUsers float64 `json:"total_users"`
        Users      []struct {
            Name      string  `json:"name"`
            Following bool    `json:"following"`
            URL       string  `json:"url"`
            Updated   float64 `json:"updated"`
        }   `json:"users"`
    }   `json:"response,omitempty"`
}

BlogFollowersResponse is a response from /followers

type BlogInfoResponse Uses

type BlogInfoResponse struct {
    Meta     `json:"meta"`
    Response struct {
        Blog Blog `json:"blog,omitempty"`
    }   `json:"response,omitempty"`
}

BlogInfoResponse is a response from /blog/info

type BlogLikesResponse Uses

type BlogLikesResponse struct {
    Meta     `json:"meta"`
    Response struct {
        LikedPosts []Post  `json:"liked_posts"`
        LikedCount float64 `json:"liked_count"`
    }   `json:"response,omitempty"`
}

BlogLikesResponse is a response from /likes

type BlogPostsResponse Uses

type BlogPostsResponse struct {
    Meta     `json:"meta"`
    Response struct {
        Blog  Blog   `json:"blog"`
        Posts []Post `json:"posts"`
    }   `json:"response,omitempty"`
}

BlogPostsResponse is a response from /posts

type ChatPost Uses

type ChatPost struct {
    Post
    // contains filtered or unexported fields
}

ChatPost represents a post of type "chat"

type Client Uses

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

Client struct that contains variables to access the tumblr api

func NewTumblrClient Uses

func NewTumblrClient(req *Request) Client

NewTumblrClient creates a new instance of Client

func (*Client) BlogAvatar Uses

func (client *Client) BlogAvatar(blogName string, size int, params ...map[string]string) *BlogAvatarResponse

BlogAvatar gets the avatar for blogName with dimensions size*size

func (*Client) BlogFollowers Uses

func (client *Client) BlogFollowers(blogName string, params ...map[string]string) *BlogFollowersResponse

BlogFollowers returns the blogs that follow blogName

func (*Client) BlogInfo Uses

func (client *Client) BlogInfo(blogName string, params ...map[string]string) *BlogInfoResponse

BlogInfo gets the information of blogName

func (*Client) BlogLikes Uses

func (client *Client) BlogLikes(blogName string, params ...map[string]string) *BlogLikesResponse

BlogLikes gets the likes of blogName

func (*Client) BlogPosts Uses

func (client *Client) BlogPosts(blogName string, params ...map[string]string) *BlogPostsResponse

BlogPosts gets posts from blogName

func (*Client) PostCreateAudio Uses

func (client *Client) PostCreateAudio(blogName string, params ...map[string]string) *PostResponse

PostCreateAudio creates a audio post on a blog

func (*Client) PostCreateChat Uses

func (client *Client) PostCreateChat(blogName string, params ...map[string]string) *PostResponse

PostCreateChat creates a chat post on a blog

func (client *Client) PostCreateLink(blogName string, params ...map[string]string) *PostResponse

PostCreateLink creates a link post on a blog

func (*Client) PostCreateQuote Uses

func (client *Client) PostCreateQuote(blogName string, params ...map[string]string) *PostResponse

PostCreateQuote creates a quote post on a blog

func (*Client) PostCreateText Uses

func (client *Client) PostCreateText(blogName string, params ...map[string]string) *PostResponse

PostCreateText creates a text post on a blog

func (*Client) PostCreateVideo Uses

func (client *Client) PostCreateVideo(blogName string, params ...map[string]string) *PostResponse

PostCreateVideo creates a video post on a blog

func (*Client) PostDelete Uses

func (client *Client) PostDelete(blogName, id string, params ...map[string]string) *PostDeleteResponse

PostDelete deletes a post with the given id

func (*Client) PostReblog Uses

func (client *Client) PostReblog(blogName, id, reblogKey string, params ...map[string]string) *PostReblogResponse

PostReblog creates a reblog on the given blogname

func (*Client) PostsDraft Uses

func (client *Client) PostsDraft(blogName string, params ...map[string]string) *PostsDraftResponse

PostsDraft returns the drafts of blogName

func (*Client) PostsQueue Uses

func (client *Client) PostsQueue(blogName string, params ...map[string]string) *PostsQueueResponse

PostsQueue returns the queue of blogName

func (*Client) PostsSubmission Uses

func (client *Client) PostsSubmission(blogName string, params ...map[string]string) *PostsSubmissionResponse

PostsSubmission returns the pending submissions of blogName

func (*Client) SendAPIRequest Uses

func (client *Client) SendAPIRequest(method, reqURL string, params map[string]string, needsAPIKey bool, kind interface{}) interface{}

SendAPIRequest sends an API request through a nice wrapper

func (*Client) Tagged Uses

func (client *Client) Tagged(tag string, params ...map[string]string) *TaggedResponse

Tagged gets posts tagged with tag

func (*Client) UserDashboard Uses

func (client *Client) UserDashboard(params ...map[string]string) *UserDashboardResponse

UserDashboard returns the user's dashboard. It takes the following params:

func (*Client) UserFollow Uses

func (client *Client) UserFollow(blogName string, params ...map[string]string) *UserFollowResponse

UserFollow follows blogName

func (*Client) UserFollowing Uses

func (client *Client) UserFollowing(params ...map[string]string) *UserFollowingResponse

UserFollowing gets the blogs that the current user is following.

:param limit: an int, the number of likes you want returned
:param offset: an int, the blog you want to start at, for pagination.
:returns: A dict created from the JSON response

func (*Client) UserInfo Uses

func (client *Client) UserInfo(params ...map[string]string) *UserInfoResponse

UserInfo gets the information of the current user

func (*Client) UserLike Uses

func (client *Client) UserLike(id, reblogKey string, params ...map[string]string) *UserLikeResponse

UserLike likes the post id of blogName

func (*Client) UserLikes Uses

func (client *Client) UserLikes(params ...map[string]string) *UserLikesResponse

UserLikes returns the user's likes

func (*Client) UserUnfollow Uses

func (client *Client) UserUnfollow(blogName string, params ...map[string]string) *UserUnfollowResponse

UserUnfollow unfollows blogName

func (*Client) UserUnlike Uses

func (client *Client) UserUnlike(id, reblogKey string, params ...map[string]string) *UserUnlikeResponse

UserUnlike unlikes the post id of blogName

type Dialogue Uses

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

Dialogue represents an individual statement in a ChatPost

type LinkPost Uses

type LinkPost struct {
    Post
    // contains filtered or unexported fields
}

LinkPost represents a Post of type "link"

type Meta Uses

type Meta struct {
    Status  float64 `json:"status"`
    Message string  `json:"msg"`
}

Meta is part of every response

type Note Uses

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

Note is a thing

type Photo Uses

type Photo struct {
    Caption  string      `json:"caption"`
    AltSizes []PhotoSize `json:"alt_sizes"`
    Width    float64     `json:"width"`
    Height   float64     `json:"height"`
}

Photo represents a Photo in a PhotoPost

type PhotoPost Uses

type PhotoPost struct {
    Photos []Photo `json:"photos"`
}

PhotoPost represents a post of type "photo"

type PhotoSize Uses

type PhotoSize struct {
    Width  float64 `json:"width"`
    Height float64 `json:"height"`
    URL    string  `json:"url"`
}

PhotoSize represents a photo at a given size

type PhotosetPost Uses

type PhotosetPost struct {
    PhotoPost
}

PhotosetPost represents a post that is a set of photos

type Post Uses

type Post struct {
    // All Posts
    BlogName    string   `json:"blog_name"`
    ID          float64  `json:"id"`
    PostURL     string   `json:"post_url"`
    Type        string   `json:"type"`
    Timestamp   float64  `json:"timestamp"`
    Date        string   `json:"date"`
    Format      string   `json:"format"`
    ReblogKey   string   `json:"reblog_key"`
    Tags        []string `json:"tags"`
    Bookmarklet bool     `json:"bookmarklet"`
    Mobile      bool     `json:"mobile"`
    SourceURL   string   `json:"source_url"`
    SourceTitle string   `json:"source_title"`
    Liked       bool     `json:"liked"`
    State       string   `json:"state"`
    TotalPosts  float64  `json:"total_posts"`
    ShortURL    string   `json:"short_url"`
    Slug        string   `json:"slug"`
    NoteCount   float64  `json:"note_count"`
    // Text Posts
    Title string `json:"title"`
    Body  string `json:"body"`
    // Photo Posts
    Photos  []Photo `json:"photos"`
    Caption string  `json:"caption"`
    Width   float64 `json:"width"`
    Height  float64 `json:"height"`
    // Quote Posts
    Source string `json:"source"`
    // Link Posts
    URL         string `json:"url"`
    Author      string `json:"author"`
    Excerpt     string `json:"excerpt"`
    Publisher   string `json:"publisher"`
    Description string `json:"description"`
    // Chat Posts
    Dialogue []struct {
        Name   string `json:"name"`
        Label  string `json:"label"`
        Phrase string `json:"phrase"`
    }   `json:"dialogue"`
    // Audio Posts
    Player      string  `json:"player"`
    Plays       float64 `json:"plays"`
    AlbumArt    string  `json:"album_art"`
    Artist      string  `json:"artist"`
    Album       string  `json:"album"`
    TrackName   string  `json:"track_name"`
    TrackNumber float64 `json:"track_number"`
    Year        float64 `json:"year"`
    // Answer Posts
    AskingName string `json:"asking_name"`
    AskingURL  string `json:"asking_url"`
    Question   string `json:"question"`
    Answer     string `json:"answer"`
    // contains filtered or unexported fields
}

Post is the base of all post types on Tumblr

type PostDeleteResponse Uses

type PostDeleteResponse struct {
    Meta     `json:"meta"`
    Response struct {
    }   `json:"response,omitempty"`
}

PostDeleteResponse is a response from /post/delete

type PostEditResponse Uses

type PostEditResponse struct {
    Meta     `json:"meta"`
    Response struct {
    }   `json:"response,omitempty"`
}

PostEditResponse is a response from /post/edit

type PostReblogResponse Uses

type PostReblogResponse struct {
    Meta     `json:"meta"`
    Response struct {
    }   `json:"response,omitempty"`
}

PostReblogResponse is a response from /post/reblog

type PostResponse Uses

type PostResponse struct {
    Meta     `json:"meta"`
    Response struct {
    }   `json:"response,omitempty"`
}

PostResponse is a response from /post

type PostcardPost Uses

type PostcardPost struct {
    Post
    // contains filtered or unexported fields
}

PostcardPost represents a post of type "postcard"

type PostsDraftResponse Uses

type PostsDraftResponse struct {
    Meta     `json:"meta"`
    Response struct {
        Blog  Blog   `json:"blog"`
        Posts []Post `json:"posts"`
    }   `json:"response,omitempty"`
}

PostsDraftResponse is a response from /posts/draft

type PostsQueueResponse Uses

type PostsQueueResponse struct {
    Meta     `json:"meta"`
    Response struct {
        Blog  Blog   `json:"blog"`
        Posts []Post `json:"posts"`
    }   `json:"response,omitempty"`
}

PostsQueueResponse is a response from /posts/queue

type PostsSubmissionResponse Uses

type PostsSubmissionResponse struct {
    Meta     `json:"meta"`
    Response struct {
        Blog  Blog   `json:"blog"`
        Posts []Post `json:"posts"`
    }   `json:"response,omitempty"`
}

PostsSubmissionResponse is a response from /posts/submission

type QuotePost Uses

type QuotePost struct {
    Post
    // contains filtered or unexported fields
}

QuotePost represents a post of type "quote"

type Request Uses

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

Request struct is a request to the tumblr api

func NewTumblrRequest Uses

func NewTumblrRequest(host, consumerKey, consumerSecret string) Request

NewTumblrRequest creates a new instance of Request

func (*Request) Get Uses

func (req *Request) Get(reqURL string, params map[string]string, client *http.Client) string

Get performs a GET request on the API

func (*Request) JSONParse Uses

func (req *Request) JSONParse(content string, dat interface{}) interface{}

JSONParse takes in web content and returns JSON

func (*Request) Post Uses

func (req *Request) Post(reqURL string, params map[string]string, client *http.Client) string

Post performs a POST request on the API

type TaggedResponse Uses

type TaggedResponse struct {
    Meta     `json:"meta"`
    Response struct {
    }   `json:"response,omitempty"`
}

TaggedResponse is a response from /tagged

type TextPost Uses

type TextPost struct {
    Post
    // contains filtered or unexported fields
}

TextPost represents a post of type "text"

type User Uses

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

User represents a User on Tumblr

type UserDashboardResponse Uses

type UserDashboardResponse struct {
    Meta     `json:"meta"`
    Response struct {
        Posts []Post `json:"posts"`
    }   `json:"response,omitempty"`
}

UserDashboardResponse is a response from /user/dashboard

type UserFollowResponse Uses

type UserFollowResponse struct {
    Meta     `json:"meta"`
    Response struct {
    }   `json:"response,omitempty"`
}

UserFollowResponse is a response from /user/follow

type UserFollowingResponse Uses

type UserFollowingResponse struct {
    Meta     `json:"meta"`
    Response struct {
        TotalBlogs float64 `json:"total_blogs"`
        Blogs      []struct {
            Name        string  `json:"name"`
            URL         string  `json:"url"`
            Updated     float64 `json:"updated"`
            Title       string  `json:"title"`
            Description string  `json:"description"`
        }
    }   `json:"response,omitempty"`
}

UserFollowingResponse is a response from /user/following

type UserInfoResponse Uses

type UserInfoResponse struct {
    Meta     `json:"meta"`
    Response struct {
        Following         float64 `json:"following"`
        DefaultPostFormat string  `json:"default_post_format"`
        Name              string  `json:"string"`
        Likes             float64 `json:"likes"`
        Blogs             []struct {
            Name      string  `json:"name"`
            URL       string  `json:"url"`
            Title     string  `json:"title"`
            Primary   bool    `json:"primary"`
            Followers float64 `json:"followers"`
            Tweet     string  `json:"tweet"`
            Facebook  string  `json:"facebook"`
            Type      string  `json:"type"`
        }   `json:"blogs"`
    }   `json:"response,omitempty"`
}

UserInfoResponse is a response from /user/info

type UserLikeResponse Uses

type UserLikeResponse struct {
    Meta     `json:"meta"`
    Response struct {
    }   `json:"response,omitempty"`
}

UserLikeResponse is a response from /user/like

type UserLikesResponse Uses

type UserLikesResponse struct {
    Meta     `json:"meta"`
    Response struct {
        Posts      []Post  `json:"liked_posts"`
        LikedCount float64 `json:"liked_count"`
    }   `json:"response,omitempty"`
}

UserLikesResponse is a response from /user/likes

type UserUnfollowResponse Uses

type UserUnfollowResponse struct {
    Meta     `json:"meta"`
    Response struct {
    }   `json:"response,omitempty"`
}

UserUnfollowResponse is a response from /user/unfollow

type UserUnlikeResponse Uses

type UserUnlikeResponse struct {
    Meta     `json:"meta"`
    Response struct {
    }   `json:"response,omitempty"`
}

UserUnlikeResponse is a response from /user/unlike

type Video Uses

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

Video represents an individual Video in a VideoPost

type VideoPost Uses

type VideoPost struct {
    Post
    // contains filtered or unexported fields
}

VideoPost represents a post of type "video"

Package tumblr imports 13 packages (graph) and is imported by 1 packages. Updated 2016-07-29. Refresh now. Tools for package owners.