Documentation
¶
Overview ¶
主动发消息
Index ¶
- Constants
- func JoinInt64(a []int64) string
- func JoinString(a []string) string
- func SplitInt64(str string) (dst []int64, err error)
- func SplitString(str string) []string
- type Client
- func (clt Client) SendFile(msg *File) (r *Result, err error)
- func (clt Client) SendImage(msg *Image) (r *Result, err error)
- func (clt Client) SendMPNews(msg *MPNews) (r *Result, err error)
- func (clt Client) SendNews(msg *News) (r *Result, err error)
- func (clt Client) SendText(msg *Text) (r *Result, err error)
- func (clt Client) SendVideo(msg *Video) (r *Result, err error)
- func (clt Client) SendVoice(msg *Voice) (r *Result, err error)
- type CommonMessageHeader
- type File
- type Image
- type MPNews
- type MPNewsArticle
- type News
- type NewsArticle
- type Result
- type Text
- type Video
- type Voice
Constants ¶
View Source
const ( MsgTypeText = "text" MsgTypeImage = "image" MsgTypeVoice = "voice" MsgTypeVideo = "video" MsgTypeFile = "file" MsgTypeNews = "news" MsgTypeMPNews = "mpnews" )
View Source
const NewsArticleCountLimit = 10
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
*corp.CorpClient
}
type CommonMessageHeader ¶
type CommonMessageHeader struct {
ToUser string `json:"touser,omitempty"` // 非必须; 员工ID列表(消息接收者,多个接收者用‘|’分隔,最多支持1000个)。特殊情况:指定为@all,则向关注该企业应用的全部成员发送
ToParty string `json:"toparty,omitempty"` // 非必须; 部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数
ToTag string `json:"totag,omitempty"` // 非必须; 标签ID列表,多个接收者用‘|’分隔。当touser为@all时忽略本参数
MsgType string `json:"msgtype"` // 必须; 消息类型
AgentId int64 `json:"agentid"` // 必须; 企业应用的id,整型
Safe *int `json:"safe,omitempty"` // 非必须; 表示是否是保密消息,0表示否,1表示是,默认0
}
type File ¶
type File struct {
CommonMessageHeader
File struct {
MediaId string `json:"media_id"` // 媒体文件id,可以调用上传媒体文件接口获取
} `json:"file"`
}
type Image ¶
type Image struct {
CommonMessageHeader
Image struct {
MediaId string `json:"media_id"` // 图片媒体文件id,可以调用上传媒体文件接口获取
} `json:"image"`
}
type MPNews ¶
type MPNews struct {
CommonMessageHeader
MPNews struct {
Articles []MPNewsArticle `json:"articles,omitempty"` // 多条图文消息信息, 默认第一个item为大图, 注意, 如果图文数超过10, 则将会无响应
} `json:"mpnews"`
}
MPNews 消息与 News 消息类似,不同的是图文消息内容存储在微信后台,并且支持保密选项。
func (*MPNews) CheckValid ¶
检查 MPNews 是否有效,有效返回 nil,否则返回错误信息
type MPNewsArticle ¶
type MPNewsArticle struct {
ThumbMediaId string `json:"thumb_media_id"` // 图文消息缩略图的media_id, 可以在上传多媒体文件接口中获得。此处thumb_media_id即上传接口返回的media_id
Title string `json:"title"` // 图文消息的标题
Author string `json:"author,omitempty"` // 图文消息的作者
ContentSourceURL string `json:"content_source_url,omitempty"` // 图文消息点击“阅读原文”之后的页面链接
Content string `json:"content"` // 图文消息的内容,支持html标签
Digest string `json:"digest,omitempty"` // 图文消息的描述
ShowCoverPic int `json:"show_cover_pic"` // 是否显示封面,1为显示,0为不显示
}
func (*MPNewsArticle) SetShowCoverPic ¶
func (article *MPNewsArticle) SetShowCoverPic(b bool)
type News ¶
type News struct {
CommonMessageHeader
News struct {
Articles []NewsArticle `json:"articles,omitempty"` // 图文消息,一个图文消息支持1到10条图文
} `json:"news"`
}
News 消息, 注意沒有 Safe 字段.
type NewsArticle ¶
type Result ¶
type Result struct {
InvalidUser string `json:"invaliduser"`
InvalidParty string `json:"invalidparty"`
InvalidTag string `json:"invalidtag"`
}
发送消息返回的数据结构
type Text ¶
type Text struct {
CommonMessageHeader
Text struct {
Content string `json:"content"`
} `json:"text"`
}
type Video ¶
type Video struct {
CommonMessageHeader
Video struct {
MediaId string `json:"media_id"` // 视频媒体文件id,可以调用上传媒体文件接口获取
Title string `json:"title,omitempty"` // 视频消息的标题
Description string `json:"description,omitempty"` // 视频消息的描述
} `json:"video"`
}
type Voice ¶
type Voice struct {
CommonMessageHeader
Voice struct {
MediaId string `json:"media_id"` // 语音文件id,可以调用上传媒体文件接口获取
} `json:"voice"`
}
Click to show internal directories.
Click to hide internal directories.