material

package
v0.0.0-...-4877452 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

README

func (clt *Client) UpdateNews 沒有測試通過

Documentation

Overview

永久素材API.

Index

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,即显示
}

func (*Article) SetShowCoverPic

func (article *Article) SetShowCoverPic(b bool)

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) AddNews

func (clt *Client) AddNews(news News) (mediaId string, err error)

新增永久图文素材.

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) DeleteMaterial

func (clt *Client) DeleteMaterial(mediaId string) (err error)

删除永久素材.

func (*Client) DownloadMaterial

func (clt *Client) DownloadMaterial(mediaId, filepath string) (err error)

下载多媒体到文件.

func (*Client) DownloadMaterialToWriter

func (clt *Client) DownloadMaterialToWriter(mediaId string, writer io.Writer) error

下载多媒体到 io.Writer.

func (*Client) GetMaterialCount

func (clt *Client) GetMaterialCount() (info *MaterialCountInfo, err error)

获取素材总数.

func (*Client) GetNews

func (clt *Client) GetNews(mediaId string) (news News, err error)

获取永久图文素材.

func (*Client) UploadImage

func (clt *Client) UploadImage(filepath string) (mediaId string, err error)

上传多媒体图片

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 (clt *Client) UploadThumb(filepath string) (mediaId string, err error)

上传多媒体缩略图

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

func (clt *Client) UploadVoice(filepath string) (mediaId string, err error)

上传多媒体语音

func (*Client) UploadVoiceFromReader

func (clt *Client) UploadVoiceFromReader(filename string, reader io.Reader) (mediaId string, err error)

上传多媒体语音

NOTE: 参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称

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 MaterialInfo struct {
	MediaId    string `json:"media_id"`    // 素材id
	Name       string `json:"name"`        // 文件名称
	UpdateTime int64  `json:"update_time"` // 最后更新时间
}

type News

type News []Article

type NewsInfo

type NewsInfo struct {
	MediaId string `json:"media_id"` // 素材id
	Content struct {
		Articles []Article `json:"news_item,omitempty"`
	} `json:"content"`
	UpdateTime int64 `json:"update_time"` // 最后更新时间
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL