wechat: github.com/silenceper/wechat/material Index | Files

package material

import "github.com/silenceper/wechat/material"

Index

Package Files

material.go media.go

Constants

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

type Article Uses

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

Article 永久图文素材

type Material Uses

type Material struct {
    *context.Context
}

Material 素材管理

func NewMaterial Uses

func NewMaterial(context *context.Context) *Material

NewMaterial init

func (*Material) AddMaterial Uses

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

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

func (*Material) AddNews Uses

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

AddNews 新增永久图文素材

func (*Material) AddVideo Uses

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

AddVideo 永久视频素材文件上传

func (*Material) DeleteMaterial Uses

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

DeleteMaterial 删除永久素材

func (*Material) GetMediaURL Uses

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

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

func (*Material) ImageUpload Uses

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

ImageUpload 图片上传

func (*Material) MediaUpload Uses

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

MediaUpload 临时素材上传

type Media Uses

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 Uses

type MediaType string

MediaType 媒体文件类型

Package material imports 5 packages (graph) and is imported by 2 packages. Updated 2018-09-15. Refresh now. Tools for package owners.