1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-13 01:02:27 +08:00

企业微信内部开发API:消息推送与接收,以及回调处理

This commit is contained in:
hb
2021-11-24 14:18:10 +08:00
parent 73adb7dcdd
commit 7ae8e08a3e
10 changed files with 445 additions and 117 deletions

41
work/message/news.go Normal file
View File

@@ -0,0 +1,41 @@
package message
//News 图文消息
type News struct {
CommonToken `json:"-"`
ArticleCount int `xml:"ArticleCount" json:"-"`
Articles []*Article `xml:"Articles>item,omitempty" json:"articles"`
}
//NewNews 初始化图文消息
func NewNews(articles []*Article) *News {
news := new(News)
news.ArticleCount = len(articles)
news.Articles = articles
return news
}
//Article 单篇文章
type Article struct {
Title string `xml:"Title,omitempty" json:"title"`
Description string `xml:"Description,omitempty" json:"description"`
PicURL string `xml:"PicUrl,omitempty" json:"picurl"`
URL string `xml:"Url,omitempty" json:"url"`
Appid string `xml:"-" json:"appid"` //仅在发送应用消息时需要
Pagepath string `xml:"-" json:"pagepath"` //仅在发送应用消息时需要
}
//MpNews 图文消息
type MpNews struct {
Articles []*MpNewsArticle `xml:"-" json:"articles"`
}
//MpNewsArticle mpnews类型的图文消息跟普通的图文消息一致唯一的差异是图文内容存储在企业微信
type MpNewsArticle struct {
Title string `json:"title"`
ThumbMediaId string `json:"thumb_media_id"`
Author string `json:"author"`
ContentSourceUrl string `json:"content_source_url"`
Content string `json:"content"`
Digest string `json:"digest"`
}