material

package
v2.1.5557 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Title            string `json:"title"`
	ThumbMediaID     string `json:"thumb_media_id"`
	ThumbURL         string `json:"thumb_url"`
	Author           string `json:"author"`
	Digest           string `json:"digest"`
	ShowCoverPic     int    `json:"show_cover_pic"`
	Content          string `json:"content"`
	ContentSourceURL string `json:"content_source_url"`
	URL              string `json:"url"`
	DownURL          string `json:"down_url"`
}

Article 永久图文素材

type ArticleList

type ArticleList struct {
	util.CommonError
	TotalCount int64             `json:"total_count"`
	ItemCount  int64             `json:"item_count"`
	Item       []ArticleListItem `json:"item"`
}

ArticleList 永久素材列表

type ArticleListContent

type ArticleListContent struct {
	NewsItem   []Article `json:"news_item"`
	UpdateTime int64     `json:"update_time"`
	CreateTime int64     `json:"create_time"`
}

ArticleListContent 用于ArticleListItem的content节点

type ArticleListItem

type ArticleListItem struct {
	MediaID    string             `json:"media_id"`
	Content    ArticleListContent `json:"content"`
	Name       string             `json:"name"`
	URL        string             `json:"url"`
	UpdateTime int64              `json:"update_time"`
}

ArticleListItem 用于ArticleList的item节点

type Material

type Material struct {
	*context.Context
}

Material 素材管理

func NewMaterial

func NewMaterial(context *context.Context) *Material

NewMaterial init

func (*Material) AddMaterial

func (material *Material) AddMaterial(mediaType MediaType, filename string) (mediaID string, url string, err error)

AddMaterial 上传永久性素材(处理视频需要单独上传)

func (*Material) AddNews

func (material *Material) AddNews(articles []*Article) (mediaID string, err error)

AddNews 新增永久图文素材

func (*Material) AddVideo

func (material *Material) AddVideo(filename, title, introduction string) (mediaID string, url string, err error)

AddVideo 永久视频素材文件上传

func (*Material) BatchGetMaterial

func (material *Material) BatchGetMaterial(permanentMaterialType PermanentMaterialType, offset, count int64) (list ArticleList, err error)

BatchGetMaterial 批量获取永久素材

func (*Material) DeleteMaterial

func (material *Material) DeleteMaterial(mediaID string) error

DeleteMaterial 删除永久素材

func (*Material) GetMaterialCount

func (material *Material) GetMaterialCount() (res ResMaterialCount, err error)

GetMaterialCount 获取素材总数.

func (*Material) GetMediaURL

func (material *Material) GetMediaURL(mediaID string) (mediaURL string, err error)

GetMediaURL 返回临时素材的下载地址供用户自己处理 NOTICE: URL 不可公开,因为含access_token 需要立即另存文件

func (*Material) GetNews

func (material *Material) GetNews(id string) ([]*Article, error)

GetNews 获取/下载永久素材

func (*Material) ImageUpload

func (material *Material) ImageUpload(filename string) (url string, err error)

ImageUpload 图片上传

func (*Material) MediaUpload

func (material *Material) MediaUpload(mediaType MediaType, filename string) (media Media, err error)

MediaUpload 临时素材上传

func (*Material) UpdateNews

func (material *Material) UpdateNews(article *Article, mediaID string, index int64) (err error)

UpdateNews 更新永久图文素材

type Media

type Media struct {
	util.CommonError

	Type         MediaType `json:"type"`
	MediaID      string    `json:"media_id"`
	ThumbMediaID string    `json:"thumb_media_id"`
	CreatedAt    int64     `json:"created_at"`
}

Media 临时素材上传返回信息

type MediaType

type MediaType string

MediaType 媒体文件类型

const (
	// MediaTypeImage 媒体文件:图片
	MediaTypeImage MediaType = "image"
	// MediaTypeVoice 媒体文件:声音
	MediaTypeVoice MediaType = "voice"
	// MediaTypeVideo 媒体文件:视频
	MediaTypeVideo MediaType = "video"
	// MediaTypeThumb 媒体文件:缩略图
	MediaTypeThumb MediaType = "thumb"
)

type PermanentMaterialType

type PermanentMaterialType string

PermanentMaterialType 永久素材类型

const (
	// PermanentMaterialTypeImage 永久素材图片类型(image)
	PermanentMaterialTypeImage PermanentMaterialType = "image"
	// PermanentMaterialTypeVideo 永久素材视频类型(video)
	PermanentMaterialTypeVideo PermanentMaterialType = "video"
	// PermanentMaterialTypeVoice 永久素材语音类型 (voice)
	PermanentMaterialTypeVoice PermanentMaterialType = "voice"
	// PermanentMaterialTypeNews 永久素材图文类型(news)
	PermanentMaterialTypeNews PermanentMaterialType = "news"
)

type ResMaterialCount

type ResMaterialCount struct {
	util.CommonError
	VoiceCount int64 `json:"voice_count"` // 语音总数量
	VideoCount int64 `json:"video_count"` // 视频总数量
	ImageCount int64 `json:"image_count"` // 图片总数量
	NewsCount  int64 `json:"news_count"`  // 图文总数量
}

ResMaterialCount 素材总数

Jump to

Keyboard shortcuts

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