Documentation ¶
Overview ¶
媒体相关操作.
Index ¶
- Constants
- type Article
- type Client
- func (clt *Client) CreateNews(articles []Article) (info *MediaInfo, err error)
- func (clt *Client) CreateVideo(mediaId, title, description string) (info *MediaInfo, err error)
- func (clt *Client) DownloadMedia(mediaId, filepath string) (err error)
- func (clt *Client) DownloadMediaToWriter(mediaId string, writer io.Writer) error
- func (clt *Client) UploadImage(filepath string) (info *MediaInfo, err error)
- func (clt *Client) UploadImageFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)
- func (clt *Client) UploadThumb(_filepath string) (info *MediaInfo, err error)
- func (clt *Client) UploadThumbFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)
- func (clt *Client) UploadVideo(filepath string) (info *MediaInfo, err error)
- func (clt *Client) UploadVideoFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)
- func (clt *Client) UploadVoice(filepath string) (info *MediaInfo, err error)
- func (clt *Client) UploadVoiceFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)
- type MediaInfo
Constants ¶
View Source
const ( MediaTypeImage = "image" MediaTypeVoice = "voice" MediaTypeVideo = "video" MediaTypeThumb = "thumb" MediaTypeNews = "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"` // 图文消息缩略图的 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为不显示 }
图文消息里的 Article
func (*Article) SetShowCoverPic ¶
type Client ¶
type Client struct {
mp.WechatClient
}
func NewClient ¶
func NewClient(TokenServer mp.TokenServer, HttpClient *http.Client) *Client
创建一个新的 Client.
如果 HttpClient == nil 则默认用 http.DefaultClient
func (*Client) CreateVideo ¶
根据上传的视频文件 media_id 创建视频媒体, 群发视频消息应该用这个函数得到的 media_id.
NOTE: title, description 可以为空.
func (*Client) DownloadMedia ¶
下载多媒体到文件.
func (*Client) DownloadMediaToWriter ¶
下载多媒体到 io.Writer.
func (*Client) UploadImage ¶
上传多媒体图片
func (*Client) UploadImageFromReader ¶
func (clt *Client) UploadImageFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)
上传多媒体图片
NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称
func (*Client) UploadThumb ¶
上传多媒体缩略图
func (*Client) UploadThumbFromReader ¶
func (clt *Client) UploadThumbFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)
上传多媒体缩略图
NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称
func (*Client) UploadVideo ¶
上传多媒体视频
func (*Client) UploadVideoFromReader ¶
func (clt *Client) UploadVideoFromReader(filename string, reader io.Reader) (info *MediaInfo, err error)
上传多媒体视频
NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称
func (*Client) UploadVoice ¶
上传多媒体语音
Click to show internal directories.
Click to hide internal directories.