media

package
v0.0.0-...-5652a87 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

临时素材API.

Index

Constants

View Source
const (
	MediaTypeImage = "image"
	MediaTypeVoice = "voice"
	MediaTypeVideo = "video"
	MediaTypeThumb = "thumb"
	MediaTypeNews  = "news"
)
View Source
const (
	NewsArticleCountLimit = 10 // 图文素材里文章的个数限制
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	ThumbMediaId     string `json:"thumb_media_id"`               // 必须; 图文消息缩略图的 media_id, 可以在上传多媒体文件接口中获得
	Title            string `json:"title"`                        // 必须; 图文消息的标题
	Author           string `json:"author,omitempty"`             // 可选; 图文消息的作者
	Digest           string `json:"digest,omitempty"`             // 可选; 图文消息的摘要
	Content          string `json:"content"`                      // 必须; 图文消息页面的内容, 支持HTML标签
	ContentSourceURL string `json:"content_source_url,omitempty"` // 可选; 在图文消息页面点击"阅读原文"后的页面
	ShowCoverPic     int    `json:"show_cover_pic"`               // 必须; 是否显示封面, 1为显示, 0为不显示
}

func (*Article) SetShowCoverPic

func (article *Article) SetShowCoverPic(b bool)

type Client

type Client mp.Client

func NewClient

func NewClient(srv mp.AccessTokenServer, clt *http.Client) *Client

func (*Client) CreateNews

func (clt *Client) CreateNews(articles []Article) (info *MediaInfo, err error)

创建图文消息素材.

func (*Client) CreateVideo

func (clt *Client) CreateVideo(mediaId, title, description string) (info *MediaInfo, err error)

创建视频素材.

mediaId:     通过上传视频文件得到
title:       标题, 可以为空
description: 描述, 可以为空

func (*Client) DownloadMedia

func (clt *Client) DownloadMedia(mediaId, filepath string) (written int64, err error)

下载多媒体到文件.

请注意, 视频文件不支持下载

func (*Client) DownloadMediaToWriter

func (clt *Client) DownloadMediaToWriter(mediaId string, writer io.Writer) (written int64, err error)

下载多媒体到 io.Writer.

请注意, 视频文件不支持下载

func (*Client) UploadImage

func (clt *Client) UploadImage(filepath string) (info *MediaInfo, err error)

上传多媒体图片

func (*Client) UploadImageFromReader

func (clt *Client) UploadImageFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)

上传多媒体图片

NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称

func (*Client) UploadImagePermanent

func (clt *Client) UploadImagePermanent(imgPath string) (info ImageInfo, err error)

上传图片到微信服务器, 给其他场景使用, 比如卡卷, POI.

func (*Client) UploadImagePermanentFromReader

func (clt *Client) UploadImagePermanentFromReader(filename string, reader io.Reader) (info ImageInfo, err error)

上传图片到微信服务器, 给其他场景使用, 比如卡卷, POI.

func (*Client) UploadThumb

func (clt *Client) UploadThumb(_filepath string) (info *MediaInfo, err error)

上传多媒体缩略图

func (*Client) UploadThumbFromReader

func (clt *Client) UploadThumbFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)

上传多媒体缩略图

NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称

func (*Client) UploadVideo

func (clt *Client) UploadVideo(filepath string) (info *MediaInfo, err error)

上传多媒体视频

func (*Client) UploadVideoFromReader

func (clt *Client) UploadVideoFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)

上传多媒体视频

NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称

func (*Client) UploadVoice

func (clt *Client) UploadVoice(filepath string) (info *MediaInfo, err error)

上传多媒体语音

func (*Client) UploadVoiceFromReader

func (clt *Client) UploadVoiceFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)

上传多媒体语音

NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称

type ImageInfo

type ImageInfo struct {
	URL string `json:"url"`
}

上传到微信服务器的图片信息.

type MediaInfo

type MediaInfo struct {
	MediaType string `json:"type"`       // 图片(image), 语音(voice), 视频(video), 缩略图(thumb)和 图文消息(news)
	MediaId   string `json:"media_id"`   // 媒体的唯一标识
	CreatedAt int64  `json:"created_at"` // 媒体创建的时间戳
}

Jump to

Keyboard shortcuts

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