media

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package media 素材管理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MediaInfo

type MediaInfo struct {
	Type      string `json:"type"`       // 媒体文件类型,分别有图片(image)、语音(voice)、视频(video),普通文件(file)
	MediaId   string `json:"media_id"`   // 媒体文件上传后获取的唯一标识,3天内有效
	CreatedAt string `json:"created_at"` // 媒体文件上传时间戳
}

type WechatMedia

type WechatMedia struct {
	Client *wecom.WechatClient
}

func NewWechatMedia

func NewWechatMedia(client *wecom.WechatClient) *WechatMedia

func (WechatMedia) GetMedia

func (w WechatMedia) GetMedia(ctx context.Context, mediaId string) (body io.ReadCloser, fn string, err error)

获取临时素材

参考文档:https://work.weixin.qq.com/api/doc#90000/90135/90254

func (WechatMedia) GetVoice

func (w WechatMedia) GetVoice(ctx context.Context, mediaId string) (body io.ReadCloser, fn string, err error)

获取高清语音素材

可以使用本接口获取从JSSDK的uploadVoice接口上传的临时语音素材,格式为speex,16K 采样率。该音频比上文的临时素材获取接口(格式为amr,8K采样率)更加清晰,适合用作语音 识别等对音质要求较高的业务。

参考文档:https://work.weixin.qq.com/api/doc#90000/90135/90255

func (WechatMedia) UploadMedia

func (w WechatMedia) UploadMedia(ctx context.Context, filename, type_ string, r io.Reader) (*MediaInfo, error)

上传临时素材

素材上传得到media_id,该media_id仅三天内有效,media_id在同一企业内应用之间可以共享

参考文档:https://work.weixin.qq.com/api/doc#90000/90135/90253

func (WechatMedia) UploadPerpetualImg

func (w WechatMedia) UploadPerpetualImg(ctx context.Context, filename string, r io.Reader) (url string, err error)

上传永久图片

参考文档:https://work.weixin.qq.com/api/doc#90000/90135/90256

Jump to

Keyboard shortcuts

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