telegraph

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: MIT Imports: 11 Imported by: 7

README

telegraph-go

Go 封装的 Telegraph API

Documentation

Overview

Copy from https://github.com/toby3d/telegraph/blob/master/content.go

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDataType = errors.New("invalid data type")

Functions

func CreatePage

func CreatePage(data *CreatePageRequest) (string, error)

CreatePage 保存文章,支持判断文章字符是否超出 64 * 1024 byte/字节,超出的话自动截取并且生成多篇文章,且自动将第二篇文章的链接添加到第一篇文章里。

func CreatePageWithClient

func CreatePageWithClient(data CreatePageRequest, client *http.Client) (string, error)

Types

type CreatePageRequest

type CreatePageRequest struct {
	AccessToken   string `json:"access_token"`
	Title         string `json:"title" validate:"max=10,min=1"`
	Content       []Node `json:"content"`
	ReturnContent string `json:"return_content"`
	Data          string `json:-`
	AuthorName    string `json:"author_name"`
	AuthorURL     string `json:"author_url"`
}

type Node

type Node interface{}

Node 代表着html数据的Node数据

func ContentFormat

func ContentFormat(data interface{}) (n []Node, err error)

ContentFormat transforms data to a DOM-based format to represent the content of the page.

type NodeElement

type NodeElement struct {
	// Name of the DOM element. Available tags: a, aside, b, blockquote, br, code, em, figcaption, figure,
	// h3, h4, hr, i, iframe, img, li, ol, p, pre, s, strong, u, ul, video.
	Tag string `json:"tag"`

	// Attributes of the DOM element. Key of object represents name of attribute, value represents value
	// of attribute. Available attributes: href, src.
	Attrs map[string]string `json:"attrs,omitempty"`

	// List of child nodes for the DOM element.
	Children []Node `json:"children,omitempty"`
}

NodeElement 是节点元素

type Page

type Page struct {
	Path string
	URL  string
}

暂时只有自己用得到的属性

type ResData

type ResData struct {
	OK     bool
	Result Page
	Error  string
}

创建Page接口返回的数据

Jump to

Keyboard shortcuts

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