Documentation ¶
Overview ¶
临时素材管理.
永久素材管理在 material 模块; 对于图文消息里的图片, 可以调用 base.UploadImage 或者 base.UploadImageFromReader 来上传.
Index ¶
- Constants
- func Download(clt *core.Client, mediaId, filepath string) (written int64, err error)
- func DownloadToWriter(clt *core.Client, mediaId string, writer io.Writer) (written int64, err error)
- type Article
- type MediaInfo
- func UploadImage(clt *core.Client, filepath string) (info *MediaInfo, err error)
- func UploadImageFromReader(clt *core.Client, filename string, reader io.Reader) (info *MediaInfo, err error)
- func UploadNews(clt *core.Client, news *News) (info *MediaInfo, err error)
- func UploadThumb(clt *core.Client, _filepath string) (info *MediaInfo, err error)
- func UploadThumbFromReader(clt *core.Client, filename string, reader io.Reader) (info *MediaInfo, err error)
- func UploadVideo(clt *core.Client, filepath string) (info *MediaInfo, err error)
- func UploadVideo2(clt *core.Client, mediaId, title, description string) (info *MediaInfo, err error)
- func UploadVideoFromReader(clt *core.Client, filename string, reader io.Reader) (info *MediaInfo, err error)
- func UploadVoice(clt *core.Client, filepath string) (info *MediaInfo, err error)
- func UploadVoiceFromReader(clt *core.Client, filename string, reader io.Reader) (info *MediaInfo, err error)
- type News
Constants ¶
View Source
const ( MediaTypeImage = "image" MediaTypeVoice = "voice" MediaTypeVideo = "video" MediaTypeThumb = "thumb" MediaTypeNews = "news" )
Variables ¶
This section is empty.
Functions ¶
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为不显示, 默认为不显示 }
type MediaInfo ¶
type MediaInfo struct { MediaType string `json:"type"` // 媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb,主要用于视频与音乐格式的缩略图) MediaId string `json:"media_id"` // 媒体文件上传后,获取时的唯一标识 CreatedAt int64 `json:"created_at"` // 媒体文件上传时间戳 }
func UploadImage ¶
UploadImage 上传多媒体图片
func UploadImageFromReader ¶
func UploadImageFromReader(clt *core.Client, filename string, reader io.Reader) (info *MediaInfo, err error)
UploadImageFromReader 上传多媒体图片
NOTE: 参数 filename 不是文件路径, 是 multipart/form-data 里面 filename 的值.
func UploadNews ¶
UploadNews 创建图文消息素材, 返回的素材一般用于群发消息.
func UploadThumb ¶
UploadThumb 上传多媒体缩略图
func UploadThumbFromReader ¶
func UploadThumbFromReader(clt *core.Client, filename string, reader io.Reader) (info *MediaInfo, err error)
UploadThumbFromReader 上传多媒体缩略图.
NOTE: 参数 filename 不是文件路径, 是 multipart/form-data 里面 filename 的值.
func UploadVideo ¶
UploadVideo 上传多媒体视频
func UploadVideo2 ¶
func UploadVideo2(clt *core.Client, mediaId, title, description string) (info *MediaInfo, err error)
UploadVideo2 创建视频素材, 返回的素材一般用于群发消息.
mediaId: 通过 UploadVideo 上传视频文件得到 title: 标题, 可以为空 description: 描述, 可以为空
func UploadVideoFromReader ¶
func UploadVideoFromReader(clt *core.Client, filename string, reader io.Reader) (info *MediaInfo, err error)
UploadVideoFromReader 上传多媒体视频
NOTE: 参数 filename 不是文件路径, 是 multipart/form-data 里面 filename 的值.
func UploadVoice ¶
UploadVoice 上传多媒体语音
Click to show internal directories.
Click to hide internal directories.