Documentation ¶
Overview ¶
定义被动回复消息到微信服务器的消息数据结构.
Index ¶
Constants ¶
View Source
const ( MSG_TYPE_TEXT = "text" // 文本消息 MSG_TYPE_IMAGE = "image" // 图片消息 MSG_TYPE_VOICE = "voice" // 语音消息 MSG_TYPE_VIDEO = "video" // 视频消息 MSG_TYPE_MUSIC = "music" // 音乐消息 MSG_TYPE_NEWS = "news" // 图文消息 MSG_TYPE_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service" // 将消息转发到多客服 )
View Source
const (
NewsArticleCountLimit = 10 // 被动回复图文消息的文章数据最大数
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommonHead ¶
type CommonHead struct { ToUserName string `xml:"ToUserName" json:"ToUserName"` // 接收方帐号(OpenID) FromUserName string `xml:"FromUserName" json:"FromUserName"` // 开发者微信号 CreateTime int64 `xml:"CreateTime" json:"CreateTime"` // 消息创建时间(整型), unixtime MsgType string `xml:"MsgType" json:"MsgType"` // 消息类型 }
type Image ¶
type Image struct { XMLName struct{} `xml:"xml" json:"-"` CommonHead Image struct { MediaId string `xml:"MediaId" json:"MediaId"` // MediaId 通过上传多媒体文件得到 } `xml:"Image" json:"Image"` }
图片消息
type Music ¶
type Music struct { XMLName struct{} `xml:"xml" json:"-"` CommonHead Music struct { Title string `xml:"Title,omitempty" json:"Title,omitempty"` // 音乐标题 Description string `xml:"Description,omitempty" json:"Description,omitempty"` // 音乐描述 MusicURL string `xml:"MusicUrl" json:"MusicUrl"` // 音乐链接 HQMusicURL string `xml:"HQMusicUrl" json:"HQMusicUrl"` // 高质量音乐链接, WIFI环境优先使用该链接播放音乐 ThumbMediaId string `xml:"ThumbMediaId" json:"ThumbMediaId"` // 缩略图的媒体id, 通过上传多媒体文件得到 } `xml:"Music" json:"Music"` }
音乐消息
type News ¶
type News struct { XMLName struct{} `xml:"xml" json:"-"` CommonHead ArticleCount int `xml:"ArticleCount" json:"ArticleCount"` // 图文消息个数, 限制为10条以内 Articles []NewsArticle `xml:"Articles>item,omitempty" json:"Articles,omitempty"` // 多条图文消息信息, 默认第一个item为大图, 注意, 如果图文数超过10, 则将会无响应 }
图文消息.
NOTE: Articles 赋值的同时也要更改 ArticleCount 字段, 建议用 NewNews() 和 News.AppendArticle()
func NewNews ¶
func NewNews(to, from string, articles []NewsArticle) (news *News)
NOTE: articles 的长度不能超过 NewsArticleCountLimit
func (*News) AppendArticle ¶
func (this *News) AppendArticle(article ...NewsArticle)
增加文章到图文消息中, 该方法会自动更新 News.ArticleCount 字段
func (*News) UpdateArticleCount ¶
func (this *News) UpdateArticleCount()
更新 this.ArticleCount 字段, 使其等于 len(this.Articles)
type NewsArticle ¶
type NewsArticle struct { Title string `xml:"Title,omitempty" json:"Title,omitempty"` // 图文消息标题 Description string `xml:"Description,omitempty" json:"Description,omitempty"` // 图文消息描述 PicURL string `xml:"PicUrl,omitempty" json:"PicUrl,omitempty"` // 图片链接, 支持JPG, PNG格式, 较好的效果为大图360*200, 小图200*200 URL string `xml:"Url,omitempty" json:"Url,omitempty"` // 点击图文消息跳转链接 }
图文消息里的 Article
func (*NewsArticle) Init ¶
func (this *NewsArticle) Init(title, description, url, picURL string)
type Text ¶
type Text struct { XMLName struct{} `xml:"xml" json:"-"` CommonHead Content string `xml:"Content" json:"Content"` // 回复的消息内容, 支持换行符 }
文本消息
type TransferToCustomerService ¶
type TransferToCustomerService struct { XMLName struct{} `xml:"xml" json:"-"` CommonHead }
将消息转发到多客服
func NewTransferToCustomerService ¶
func NewTransferToCustomerService(to, from string) *TransferToCustomerService
type TransferToSpecialCustomerService ¶
type TransferToSpecialCustomerService struct { XMLName struct{} `xml:"xml" json:"-"` CommonHead TransInfo struct { KfAccount string `xml:"KfAccount" json:"KfAccount"` } `xml:"TransInfo" json:"TransInfo"` }
将消息转发到指定客服
func NewTransferToSpecialCustomerService ¶
func NewTransferToSpecialCustomerService(to, from, KfAccount string) (msg *TransferToSpecialCustomerService)
type Video ¶
type Video struct { XMLName struct{} `xml:"xml" json:"-"` CommonHead Video struct { MediaId string `xml:"MediaId" json:"MediaId"` // MediaId 通过上传多媒体文件得到 Title string `xml:"Title,omitempty" json:"Title,omitempty"` // 视频消息的标题 Description string `xml:"Description,omitempty" json:"Description,omitempty"` // 视频消息的描述 } `xml:"Video" json:"Video"` }
视频消息
Click to show internal directories.
Click to hide internal directories.