hatena

package module
v0.0.0-...-348e6ed Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2017 License: MIT Imports: 12 Imported by: 0

README

hatena-go

GoDoc Build Status Coverage Status Codacy grade Go Report Card Sourcegraph for Repo Reference Count License

Overview

This is a Go wrapper for working with Hatena WEB API.
It aims to support Hatena Bookmark Web API Endpoint.

Installation

go get github.com/8pockets/hatena-go

Authentication

Hatena uses OAuth1 for authentication and authorization.
A part of Web API endpoints require an access token.

auth := hatena.NewAuthenticator(ConsumerKey, ConsumerSecret, redirectURI, scopes)

Hatena's Web API Authorization Guide:
http://developer.hatena.ne.jp/ja/documents/auth/apis/oauth

API Examples

Examples of the API can be found in the examples directory.

License

MIT

Author

8pockets

Documentation

Index

Constants

View Source
const (
	ReadPublic   = "read_public"
	ReadPrivate  = "read_private"
	WritePublic  = "write_public"
	WritePrivate = "write_private"
)

Variables

View Source
var (
	// DefaultClient is the default client that is used by the wrapper functions
	// that don't require authorization.  If you need to authenticate, create
	// your own client with `Authenticator.NewClient`.
	DefaultClient = &Client{
		http: new(http.Client),
	}
)

Functions

func Count

func Count(urlStr string) (int, error)

はてなブックマーク件数取得API

Types

type Authenticator

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

func NewAuthenticator

func NewAuthenticator(consumerKey string, consumerSecret string, redirectUri string, scopes []string) *Authenticator

func (*Authenticator) AddBookmark

func (a *Authenticator) AddBookmark(br BookmarkForm) (*Bookmark, error)

ブックマーク API ブックマークを追加または更新する

func (*Authenticator) AuthURL

func (a *Authenticator) AuthURL(w http.ResponseWriter, r *http.Request) (string, error)

func (*Authenticator) DeleteBookmark

func (a *Authenticator) DeleteBookmark(uri string) (bool, error)

ブックマーク API ブックマークを削除する

func (*Authenticator) GetBookmark

func (a *Authenticator) GetBookmark(uri string) (*Bookmark, error)

ブックマーク API ブックマーク情報を取得する

func (*Authenticator) GetBookmarkedEntry

func (a *Authenticator) GetBookmarkedEntry(uri string) (*BookmarkEntry, error)

エントリー API ブックマークされたエントリーの情報を取得する

func (*Authenticator) GetProfile

func (a *Authenticator) GetProfile() (*Profile, error)

はてなブックマークの

func (*Authenticator) Token

type Bookmark

type Bookmark struct {
	CommentRaw      string   `json:"comment_raw"`
	Private         bool     `json:"private"`
	Eid             int      `json:"eid"`
	CreatedEpoch    int      `json:"created_epoch"`
	Tags            []string `json:"tags"`
	Permalink       string   `json:"permalink"`
	Comment         string   `json:"comment"`
	CreatedDatetime string   `json:"created_datetime"`
	User            string   `json:"user"`
}

type BookmarkEntry

type BookmarkEntry struct {
	Count                 int    `json:"count"`
	FaviconURL            string `json:"favicon_url"`
	Eid                   int    `json:"eid"`
	ImageLastEditor       string `json:"image_last_editor"`
	EntryURL              string `json:"entry_url"`
	RootURL               string `json:"root_url"`
	IsInvalidURL          bool   `json:"is_invalid_url"`
	SmartphoneAppEntryURL string `json:"smartphone_app_entry_url"`
	TitleLastEditor       string `json:"title_last_editor"`
	ImageURL              string `json:"image_url"`
	URL                   string `json:"url"`
	Title                 string `json:"title"`
	HasAsin               bool   `json:"has_asin"`
	ImageHatenaURL        string `json:"image_hatena_url"`
}

type BookmarkForm

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

type BookmarkUser

type BookmarkUser struct {
	User      string   `json:"user"`
	Comment   string   `json:"comment"`
	Timestamp string   `json:"timestamp"`
	Tags      []string `json:"tags"`
}

type Client

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

Client is a client for working with the Hatena Web API. To create an authenticated client, use the `Authenticator.NewClient` method. If you don't need to authenticate, you can use `DefaultClient`.

func (*Client) Count

func (c *Client) Count(urlStr string) (int, error)

func (*Client) EntryInfo

func (c *Client) EntryInfo(urlStr string) (*EntryInformation, error)

func (*Client) GetStar

func (c *Client) GetStar(urlStr string) (*EntryStars, error)

func (*Client) HotEntry

func (c *Client) HotEntry(category string) (*Entries, error)

func (*Client) HotEntryAll

func (c *Client) HotEntryAll() (*Entries, error)

func (*Client) NewEntry

func (c *Client) NewEntry(category string, options map[string]string) (*Entries, error)

func (*Client) NewEntryAll

func (c *Client) NewEntryAll(options map[string]string) (*Entries, error)

func (*Client) SearchEntry

func (c *Client) SearchEntry(searchWord string, searchType string, options map[string]string) (*Entries, error)

func (*Client) SearchUrlEntry

func (c *Client) SearchUrlEntry(searchUrl string, options map[string]string) (*Entries, error)

func (*Client) UserStar

func (c *Client) UserStar(username string) (*UserStars, error)

type ColoredStars

type ColoredStars struct {
	Stars []Star `json:"stars"`
	Color string `json:"color"`
}

type Entries

type Entries struct {
	Title       string  `xml:"channel>title"`
	Link        string  `xml:"channel>link"`
	Description string  `xml:"channel>description"`
	Entry       []Entry `xml:"item"`
}

func HotEntry

func HotEntry(category string) (*Entries, error)

Categories : social, economics, life, knowledge, it, fun, entertainment, game

func HotEntryAll

func HotEntryAll() (*Entries, error)

func NewEntry

func NewEntry(category string, options map[string]string) (*Entries, error)

Categories : social, economics, life, knowledge, it, fun, entertainment, game Option : sort=recent, sort=popular, threshold={3}

func NewEntryAll

func NewEntryAll(options map[string]string) (*Entries, error)

func SearchEntry

func SearchEntry(searchWord string, searchType string, options map[string]string) (*Entries, error)

searchType : keyword, title, tag Option : sort=recent, sort=popular, threshold={10}, date_begin={YYYY-MM-DD}, date_end={YYYY-MM-DD}, safe={on/off}

func SearchUrlEntry

func SearchUrlEntry(searchUrl string, options map[string]string) (*Entries, error)

Option : sort=count, sort=eid, sort=recent

type Entry

type Entry struct {
	Title         string `xml:"title"`
	Link          string `xml:"link"`
	Description   string `xml:"description"`
	Date          string `xml:"date"`
	Subject       string `xml:"subject"`
	Bookmarkcount int    `xml:"bookmarkcount"`
}

type EntryInformation

type EntryInformation struct {
	Eid            int            `json:"eid"`
	Title          string         `json:"title"`
	Count          int            `json:"count"`
	Url            string         `json:"url"`
	EntryUrl       string         `json:"entry_url"`
	Screenshot     string         `json:"screenshot"`
	Bookmarks      []BookmarkUser `json:"bookmarks"`
	RelatedEntries []RelatedEntry `json:"related"`
}

func EntryInfo

func EntryInfo(urlStr string) (*EntryInformation, error)

はてなブックマークエントリー情報取得API

type EntryPost

type EntryPost struct {
	Stars        []Star         `json:"stars"`
	CanComment   int            `json:"can_comment"`
	ColoredStars []ColoredStars `json:"colored_stars"`
	URI          string         `json:"uri"`
}

type EntryStars

type EntryStars struct {
	Entries    []EntryPost `json:"entries"`
	CanComment int         `json:"can_comment"`
}

func GetStar

func GetStar(urlStr string) (*EntryStars, error)

はてなスター取得 API ある URL に対して付与されたスターを取得できる。

type Profile

type Profile struct {
	IsOauthMixiCheck    bool   `json:"is_oauth_mixi_check"`
	MixiCheckChecked    string `json:"mixi_check_checked"`
	IgnoresRegex        string `json:"ignores_regex"`
	IsOauthEvernote     bool   `json:"is_oauth_evernote"`
	TwitterChecked      string `json:"twitter_checked"`
	Plususer            bool   `json:"plususer"`
	BookmarkCount       int    `json:"bookmark_count"`
	UserPageVersion     string `json:"user_page_version"`
	DefaultSharedLinkTo string `json:"default_shared_link_to"`
	EvernoteChecked     string `json:"evernote_checked"`
	FacebookChecked     string `json:"facebook_checked"`
	Name                string `json:"name"`
	Private             bool   `json:"private"`
	Rkm                 string `json:"rkm"`
	IsOauthTwitter      bool   `json:"is_oauth_twitter"`
	Login               bool   `json:"login"`
	Rks                 string `json:"rks"`
	IsOauthFacebook     bool   `json:"is_oauth_facebook"`
	IsStaff             bool   `json:"is_staff"`
}

type RelatedEntry

type RelatedEntry struct {
	Eid      int    `json:"eid"`
	Title    string `json:"title"`
	Count    int    `json:"count"`
	Url      string `json:"url"`
	EntryUrl string `json:"entry_url"`
}

type Star

type Star struct {
	Count int    `json:"count"`
	Quote string `json:"quote"`
	Name  string `json:"name"`
}

type UserStars

type UserStars struct {
	Count struct {
		Green  int    `json:"green"`
		Blue   int    `json:"blue"`
		Red    int    `json:"red"`
		Purple int    `json:"purple"`
		Yellow string `json:"yellow"`
	} `json:"count"`
	Title     string `json:"title"`
	URI       string `json:"uri"`
	StarCount int    `json:"star_count"`
}

func UserStar

func UserStar(username string) (*UserStars, error)

はてなスターカウントAPI 「指定したブログのエントリに全部でいくつのスターがつけられているのか」という総数を取得できるAPI

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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