Documentation
¶
Overview ¶
永久素材API.
Index ¶
- Constants
- type Article
- type Client
- func (clt Client) AddNews(news News) (mediaId string, err error)
- func (clt Client) BatchGetMaterial(materialType string, offset, count int) (TotalCount, ItemCount int, Items []MaterialInfo, err error)
- func (clt Client) BatchGetNews(offset, count int) (TotalCount, ItemCount int, Items []NewsInfo, err error)
- func (clt Client) DeleteMaterial(mediaId string) (err error)
- func (clt Client) DownloadMaterial(mediaId, filepath string) (err error)
- func (clt Client) DownloadMaterialToWriter(mediaId string, writer io.Writer) 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) UpdateNews(mediaId string, index int, article *Article) (err error)
- func (clt Client) UploadImage(filepath string) (mediaId string, err error)
- func (clt Client) UploadImageFromReader(filename string, reader io.Reader) (mediaId string, err error)
- func (clt Client) UploadThumb(filepath string) (mediaId string, err error)
- func (clt Client) UploadThumbFromReader(filename string, reader io.Reader) (mediaId 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 News
- type NewsInfo
- 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) MediaPath string `json:"media_path"` 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 Client ¶
type Client struct {
*mp.WechatClient
}
func NewClient ¶
func NewClient(AccessTokenServer mp.AccessTokenServer, httpClient *http.Client) Client
兼容保留, 建議實際項目全局維護一個 *mp.WechatClient
func (Client) BatchGetMaterial ¶
func (clt Client) BatchGetMaterial(materialType string, offset, count int) (TotalCount, ItemCount int, Items []MaterialInfo, err error)
获取素材列表.
materialType: 素材的类型,图片(image)、视频(video)、语音 (voice) offset: 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回 count: 返回素材的数量,取值在1到20之间 TotalCount: 该类型的素材的总数 ItemCount: 本次调用获取的素材的数量 Items: 本次调用获取的素材
func (Client) BatchGetNews ¶
func (clt Client) BatchGetNews(offset, count int) (TotalCount, ItemCount int, Items []NewsInfo, err error)
获取图文素材列表.
offset: 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回 count: 返回素材的数量,取值在1到20之间 TotalCount: 该类型的素材的总数 ItemCount: 本次调用获取的素材的数量 Items: 本次调用获取的素材
func (Client) DownloadMaterial ¶
下载多媒体到文件.
func (Client) DownloadMaterialToWriter ¶
下载多媒体到 io.Writer.
func (Client) GetMaterialCount ¶
func (clt Client) GetMaterialCount() (info *MaterialCountInfo, err error)
获取素材总数.
func (Client) UploadImage ¶
上传多媒体图片
func (Client) UploadImageFromReader ¶
func (clt Client) UploadImageFromReader(filename string, reader io.Reader) (mediaId string, err error)
上传多媒体图片
NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称
func (Client) UploadThumb ¶
上传多媒体缩略图
func (Client) UploadThumbFromReader ¶
func (clt Client) UploadThumbFromReader(filename string, reader io.Reader) (mediaId 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 ¶
Click to show internal directories.
Click to hide internal directories.