Documentation ¶
Overview ¶
永久素材管理.
临时素材管理在 media 模块; 对于图文消息里的图片, 可以调用 base.UploadImage 或者 base.UploadImageFromReader 来上传.
Index ¶
- Constants
- func AddNews(clt *core.Client, news *News) (mediaId string, err error)
- func Delete(clt *core.Client, mediaId string) (err error)
- 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)
- func UpdateNews(clt *core.Client, mediaId string, index int, article *Article) (err error)
- func UploadImage(clt *core.Client, _filepath string) (mediaId, url string, err error)
- func UploadImageFromReader(clt *core.Client, filename string, reader io.Reader) (mediaId, url string, err error)
- func UploadThumb(clt *core.Client, _filepath string) (mediaId, url string, err error)
- func UploadThumbFromReader(clt *core.Client, filename string, reader io.Reader) (mediaId, url string, err error)
- func UploadVideo(clt *core.Client, _filepath string, title, introduction string) (mediaId string, err error)
- func UploadVideoFromReader(clt *core.Client, filename string, reader io.Reader, ...) (mediaId string, err error)
- func UploadVoice(clt *core.Client, _filepath string) (mediaId string, err error)
- func UploadVoiceFromReader(clt *core.Client, filename string, reader io.Reader) (mediaId string, err error)
- type Article
- type BatchGetNewsResult
- type BatchGetResult
- type MaterialCountInfo
- type MaterialInfo
- type MaterialIterator
- type News
- type NewsInfo
- type NewsIterator
- type Video
Constants ¶
View Source
const ( MaterialTypeImage = "image" MaterialTypeVoice = "voice" MaterialTypeVideo = "video" MaterialTypeThumb = "thumb" MaterialTypeNews = "news" )
Variables ¶
This section is empty.
Functions ¶
func DownloadToWriter ¶
func DownloadToWriter(clt *core.Client, mediaId string, writer io.Writer) (written int64, err error)
DownloadToWriter 下载多媒体到 io.Writer.
对于视频素材, 先通过 GetVideo 得到 Video 信息, 然后通过 Video.DownloadURL 来下载
func UpdateNews ¶
修改永久图文素材.
func UploadImage ¶
UploadImage 上传多媒体图片
func UploadImageFromReader ¶
func UploadImageFromReader(clt *core.Client, filename string, reader io.Reader) (mediaId, url string, err error)
UploadImageFromReader 上传多媒体图片
NOTE: 参数 filename 不是文件路径, 是 multipart/form-data 里面 filename 的值.
func UploadThumb ¶
UploadThumb 上传多媒体缩略图
func UploadThumbFromReader ¶
func UploadThumbFromReader(clt *core.Client, filename string, reader io.Reader) (mediaId, url string, err error)
UploadThumbFromReader 上传多媒体缩略图
NOTE: 参数 filename 不是文件路径, 是 multipart/form-data 里面 filename 的值.
func UploadVideo ¶
func UploadVideo(clt *core.Client, _filepath string, title, introduction string) (mediaId string, err error)
UploadVideo 上传多媒体视频.
func UploadVideoFromReader ¶
func UploadVideoFromReader(clt *core.Client, filename string, reader io.Reader, title, introduction string) (mediaId string, err error)
UploadVideoFromReader 上传多媒体缩视频.
NOTE: 参数 filename 不是文件路径, 是 multipart/form-data 里面 filename 的值.
func UploadVoice ¶
UploadVoice 上传多媒体语音
Types ¶
type Article ¶
type Article struct { ThumbMediaId string `json:"thumb_media_id"` // 图文消息的封面图片素材id(必须是永久mediaID) Title string `json:"title"` // 标题 Author string `json:"author,omitempty"` // 作者 Digest string `json:"digest,omitempty"` // 图文消息的摘要, 仅有单图文消息才有摘要, 多图文此处为空 Content string `json:"content"` // 图文消息的具体内容, 支持HTML标签, 必须少于2万字符, 小于1M, 且此处会去除JS ContentSourceURL string `json:"content_source_url,omitempty"` // 图文消息的原文地址, 即点击"阅读原文"后的URL ShowCoverPic int `json:"show_cover_pic"` // 是否显示封面, 0为false, 即不显示, 1为true, 即显示 URL string `json:"url,omitempty"` // !!!创建时不需要此参数!!! 图文页的URL, 文章创建成功以后, 会由微信自动生成 }
type BatchGetNewsResult ¶
type BatchGetNewsResult struct { TotalCount int `json:"total_count"` // 该类型的素材的总数 ItemCount int `json:"item_count"` // 本次调用获取的素材的数量 Items []NewsInfo `json:"item"` // 本次调用获取的素材列表 }
func BatchGetNews ¶
func BatchGetNews(clt *core.Client, offset, count int) (rslt *BatchGetNewsResult, err error)
获取图文素材列表.
offset: 从全部素材的该偏移位置开始返回, 0表示从第一个素材 count: 返回素材的数量, 取值在1到20之间
type BatchGetResult ¶
type BatchGetResult struct { TotalCount int `json:"total_count"` // 该类型的素材的总数 ItemCount int `json:"item_count"` // 本次调用获取的素材的数量 Items []MaterialInfo `json:"item"` // 本次调用获取的素材列表 }
type MaterialCountInfo ¶
type MaterialCountInfo struct { VoiceCount int `json:"voice_count"` VideoCount int `json:"video_count"` ImageCount int `json:"image_count"` NewsCount int `json:"news_count"` }
公众号永久素材总数信息
func GetMaterialCount ¶
func GetMaterialCount(clt *core.Client) (info *MaterialCountInfo, err error)
获取素材总数数据.
type MaterialInfo ¶
type MaterialIterator ¶
type MaterialIterator struct {
// contains filtered or unexported fields
}
MaterialIterator
iter, err := NewMaterialIterator(clt, MaterialTypeImage, 0, 10) if err != nil { // TODO: 增加你的代码 } for iter.HasNext() { items, err := iter.NextPage() if err != nil { // TODO: 增加你的代码 } // TODO: 增加你的代码 }
func NewMaterialIterator ¶
func (*MaterialIterator) HasNext ¶
func (iter *MaterialIterator) HasNext() bool
func (*MaterialIterator) NextPage ¶
func (iter *MaterialIterator) NextPage() (items []MaterialInfo, err error)
func (*MaterialIterator) TotalCount ¶
func (iter *MaterialIterator) TotalCount() int
type NewsIterator ¶
type NewsIterator struct {
// contains filtered or unexported fields
}
NewsIterator
iter, err := NewNewsIterator(clt, 0, 10) if err != nil { // TODO: 增加你的代码 } for iter.HasNext() { items, err := iter.NextPage() if err != nil { // TODO: 增加你的代码 } // TODO: 增加你的代码 }
func NewNewsIterator ¶
func NewNewsIterator(clt *core.Client, offset, count int) (iter *NewsIterator, err error)
func (*NewsIterator) HasNext ¶
func (iter *NewsIterator) HasNext() bool
func (*NewsIterator) NextPage ¶
func (iter *NewsIterator) NextPage() (items []NewsInfo, err error)
func (*NewsIterator) TotalCount ¶
func (iter *NewsIterator) TotalCount() int
Click to show internal directories.
Click to hide internal directories.