Documentation ¶
Overview ¶
永久素材API.
Index ¶
- Constants
- type Article
- type BatchGetMaterialResult
- type BatchGetNewsResult
- type Client
- func (clt *Client) AddNews(news News) (mediaId string, err error)
- func (clt *Client) BatchGetMaterial(MaterialType string, offset, count int) (rslt *BatchGetMaterialResult, err error)
- func (clt *Client) BatchGetNews(offset, count int) (rslt *BatchGetNewsResult, err error)
- func (clt *Client) DeleteMaterial(mediaId string) (err error)
- func (clt *Client) DownloadMaterial(mediaId, filepath string) (written int64, err error)
- func (clt *Client) DownloadMaterialToWriter(mediaId string, writer io.Writer) (written int64, err error)
- func (clt *Client) GetMaterialCount() (info *MaterialCountInfo, err error)
- func (clt *Client) GetNews(mediaId string) (news News, err error)
- func (clt *Client) GetVideo(mediaId string) (info *VideoInfo, err error)
- func (clt *Client) MaterialIterator(MaterialType string, offset, count int) (iter *MaterialIterator, err error)
- func (clt *Client) NewsIterator(offset, count int) (iter *NewsIterator, err error)
- func (clt *Client) UpdateNews(mediaId string, index int, article *Article) (err error)
- func (clt *Client) UploadImage(filepath string) (mediaId, _url string, err error)
- func (clt *Client) UploadImageFromReader(filename string, reader io.Reader) (mediaId, _url string, err error)
- func (clt *Client) UploadThumb(filepath string) (mediaId, _url string, err error)
- func (clt *Client) UploadThumbFromReader(filename string, reader io.Reader) (mediaId, _url string, err error)
- func (clt *Client) UploadVideo(_filepath string, title, introduction string) (mediaId string, err error)
- func (clt *Client) UploadVideoFromReader(filename string, reader io.Reader, title, introduction string) (mediaId string, err error)
- func (clt *Client) UploadVoice(_filepath string) (mediaId string, err error)
- func (clt *Client) UploadVoiceFromReader(filename string, reader io.Reader) (mediaId string, err error)
- type MaterialCountInfo
- type MaterialInfo
- type MaterialIterator
- type News
- type NewsInfo
- type NewsIterator
- type VideoInfo
Constants ¶
View Source
const ( MaterialTypeImage = "image" MaterialTypeVoice = "voice" MaterialTypeVideo = "video" MaterialTypeThumb = "thumb" MaterialTypeNews = "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"` // 必须; 图文消息的封面图片素材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, 文章创建成功以后, 会由微信自动生成 }
func (*Article) SetShowCoverPic ¶
type BatchGetMaterialResult ¶
type BatchGetMaterialResult struct { TotalCount int `json:"total_count"` // 该类型的素材的总数 ItemCount int `json:"item_count"` // 本次调用获取的素材的数量 Items []MaterialInfo `json:"item"` // 本次调用获取的素材列表 }
type BatchGetNewsResult ¶
type Client ¶
func (*Client) BatchGetMaterial ¶
func (clt *Client) BatchGetMaterial(MaterialType string, offset, count int) (rslt *BatchGetMaterialResult, err error)
获取素材列表.
MaterialType: 素材的类型, 图片(image), 视频(video), 语音 (voice) offset: 从全部素材的该偏移位置开始返回, 0表示从第一个素材 count: 返回素材的数量, 取值在1到20之间
func (*Client) BatchGetNews ¶
func (clt *Client) BatchGetNews(offset, count int) (rslt *BatchGetNewsResult, err error)
获取图文素材列表.
offset: 从全部素材的该偏移位置开始返回, 0表示从第一个素材 返回 count: 返回素材的数量, 取值在1到20之间
func (*Client) DeleteMaterial ¶
删除永久素材.
func (*Client) DownloadMaterial ¶
下载多媒体到文件.
对于视频素材, 先通过 Client.GetVideo 得到 VideoInfo, 然后通过 VideoInfo.DownURL 来下载
func (*Client) DownloadMaterialToWriter ¶
func (clt *Client) DownloadMaterialToWriter(mediaId string, writer io.Writer) (written int64, err error)
下载多媒体到 io.Writer.
对于视频素材, 先通过 Client.GetVideo 得到 VideoInfo, 然后通过 VideoInfo.DownURL 来下载
func (*Client) GetMaterialCount ¶
func (clt *Client) GetMaterialCount() (info *MaterialCountInfo, err error)
获取素材总数.
func (*Client) MaterialIterator ¶
func (clt *Client) MaterialIterator(MaterialType string, offset, count int) (iter *MaterialIterator, err error)
func (*Client) NewsIterator ¶
func (clt *Client) NewsIterator(offset, count int) (iter *NewsIterator, err error)
func (*Client) UpdateNews ¶
修改永久图文素材.
func (*Client) UploadImage ¶
上传多媒体图片
func (*Client) UploadImageFromReader ¶
func (clt *Client) UploadImageFromReader(filename string, reader io.Reader) (mediaId, _url string, err error)
上传多媒体图片
NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称
func (*Client) UploadThumb ¶
上传多媒体缩略图
func (*Client) UploadThumbFromReader ¶
func (clt *Client) UploadThumbFromReader(filename string, reader io.Reader) (mediaId, _url string, err error)
上传多媒体缩略图
NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称
func (*Client) UploadVideo ¶
func (clt *Client) UploadVideo(_filepath string, title, introduction string) (mediaId string, err error)
上传多媒体视频
func (*Client) UploadVideoFromReader ¶
func (clt *Client) UploadVideoFromReader(filename string, reader io.Reader, title, introduction string) (mediaId string, err error)
上传多媒体缩视频
NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称
func (*Client) UploadVoice ¶
上传多媒体语音
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"` }
公众号永久素材总数信息
type MaterialInfo ¶
type MaterialIterator ¶
type MaterialIterator struct {
// contains filtered or unexported fields
}
MaterialIterator
iter, err := Client.MaterialIterator(MaterialTypeImage, 0, 10) if err != nil { // TODO: 增加你的代码 } for iter.HasNext() { items, err := iter.NextPage() if err != nil { // TODO: 增加你的代码 } // TODO: 增加你的代码 }
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 := Client.NewsIterator(0, 10) if err != nil { // TODO: 增加你的代码 } for iter.HasNext() { items, err := iter.NextPage() if err != nil { // TODO: 增加你的代码 } // TODO: 增加你的代码 }
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.