Documentation
¶
Overview ¶
自定义菜单接口.
Index ¶
- Constants
- func AddConditionalMenu(clt *core.Client, menu *Menu) (menuId int64, err error)
- func Create(clt *core.Client, menu *Menu) (err error)
- func Delete(clt *core.Client) (err error)
- func DeleteConditionalMenu(clt *core.Client, menuId int64) (err error)
- func Get(clt *core.Client) (menu *Menu, conditionalMenus []Menu, err error)
- type Article
- type Button
- func (btn *Button) SetAsClickButton(name, key string)
- func (btn *Button) SetAsLocationSelectButton(name, key string)
- func (btn *Button) SetAsMediaIdButton(name, mediaId string)
- func (btn *Button) SetAsMiniProgramButton(name, appId, pagePath, url string)
- func (btn *Button) SetAsPicPhotoOrAlbumButton(name, key string)
- func (btn *Button) SetAsPicSysPhotoButton(name, key string)
- func (btn *Button) SetAsPicWeixinButton(name, key string)
- func (btn *Button) SetAsScanCodePushButton(name, key string)
- func (btn *Button) SetAsScanCodeWaitMsgButton(name, key string)
- func (btn *Button) SetAsSubMenuButton(name string, subButtons []Button)
- func (btn *Button) SetAsViewButton(name, url string)
- func (btn *Button) SetAsViewLimitedButton(name, mediaId string)
- type ButtonEx
- type ClickEvent
- type LocationSelectEvent
- type MatchRule
- type Menu
- type MenuInfo
- type MiniProgramEvent
- type PicPhotoOrAlbumEvent
- type PicSysPhotoEvent
- type PicWeixinEvent
- type ScanCodePushEvent
- type ScanCodeWaitMsgEvent
- type ViewEvent
Constants ¶
const ( EventTypeClick core.EventType = "CLICK" // 点击菜单拉取消息时的事件推送 EventTypeView core.EventType = "VIEW" // 点击菜单跳转链接时的事件推送 // 请注意, 下面的事件仅支持微信iPhone5.4.1以上版本, 和Android5.4以上版本的微信用户, // 旧版本微信用户点击后将没有回应, 开发者也不能正常接收到事件推送. EventTypeScanCodePush core.EventType = "scancode_push" // 扫码推事件的事件推送 EventTypeScanCodeWaitMsg core.EventType = "scancode_waitmsg" // 扫码推事件且弹出"消息接收中"提示框的事件推送 EventTypePicSysPhoto core.EventType = "pic_sysphoto" // 弹出系统拍照发图的事件推送 EventTypePicPhotoOrAlbum core.EventType = "pic_photo_or_album" // 弹出拍照或者相册发图的事件推送 EventTypePicWeixin core.EventType = "pic_weixin" // 弹出微信相册发图器的事件推送 EventTypeLocationSelect core.EventType = "location_select" // 弹出地理位置选择器的事件推送 EventTypeMiniProgram core.EventType = "view_miniprogram" // 点击菜单小程序链接的事件推送 )
const ( // 下面6个类型(包括view类型)的按钮是在公众平台官网发布的菜单按钮类型 ButtonTypeText = "text" ButtonTypeImage = "img" ButtonTypePhoto = "photo" ButtonTypeVideo = "video" ButtonTypeVoice = "voice" ButtonTypeView = "view" // 跳转URL ButtonTypeClick = "click" // 点击推事件 ButtonTypeMiniProgram = "miniprogram" // 小程序 // 下面的按钮类型仅支持微信 iPhone5.4.1 以上版本, 和 Android5.4 以上版本的微信用户, // 旧版本微信用户点击后将没有回应, 开发者也不能正常接收到事件推送. ButtonTypeScanCodePush = "scancode_push" // 扫码推事件 ButtonTypeScanCodeWaitMsg = "scancode_waitmsg" // 扫码带提示 ButtonTypePicSysPhoto = "pic_sysphoto" // 系统拍照发图 ButtonTypePicPhotoOrAlbum = "pic_photo_or_album" // 拍照或者相册发图 ButtonTypePicWeixin = "pic_weixin" // 微信相册发图 ButtonTypeLocationSelect = "location_select" // 发送位置 // 下面的按钮类型专门给第三方平台旗下未微信认证(具体而言, 是资质认证未通过)的订阅号准备的事件类型, // 它们是没有事件推送的, 能力相对受限, 其他类型的公众号不必使用. ButtonTypeMediaId = "media_id" // 下发消息 ButtonTypeViewLimited = "view_limited" // 跳转图文消息URL )
Variables ¶
This section is empty.
Functions ¶
func AddConditionalMenu ¶
创建个性化菜单.
func DeleteConditionalMenu ¶
删除个性化菜单.
Types ¶
type Article ¶
type Article struct {
Title string `json:"title,omitempty"` // 图文消息的标题
Author string `json:"author,omitempty"` // 作者
Digest string `json:"digest,omitempty"` // 摘要
ShowCover int `json:"show_cover"` // 是否显示封面, 0为不显示, 1为显示
CoverURL string `json:"cover_url,omitempty"` // 封面图片的URL
ContentURL string `json:"content_url,omitempty"` // 正文的URL
SourceURL string `json:"source_url,omitempty"` // 原文的URL, 若置空则无查看原文入口
}
type Button ¶
type Button struct {
Type string `json:"type,omitempty"` // 非必须; 菜单的响应动作类型
Name string `json:"name,omitempty"` // 必须; 菜单标题
Key string `json:"key,omitempty"` // 非必须; 菜单KEY值, 用于消息接口推送
URL string `json:"url,omitempty"` // 非必须; 网页链接, 用户点击菜单可打开链接
MediaId string `json:"media_id,omitempty"` // 非必须; 调用新增永久素材接口返回的合法media_id
AppId string `json:"appid,omitempty"` // 非必须; 跳转到小程序的appid
PagePath string `json:"pagepath,omitempty"` // 非必须; 跳转到小程序的path
SubButtons []Button `json:"sub_button,omitempty"` // 非必须; 二级菜单数组
}
func (*Button) SetAsClickButton ¶
设置 btn 指向的 Button 为 click 类型按钮.
func (*Button) SetAsLocationSelectButton ¶
设置 btn 指向的 Button 为 弹出地理位置选择器 类型按钮.
func (*Button) SetAsMediaIdButton ¶
设置 btn 指向的 Button 为 下发消息(除文本消息) 类型按钮.
func (*Button) SetAsMiniProgramButton ¶
设置 btn 指向的 Button 为 打开小程序.
func (*Button) SetAsPicPhotoOrAlbumButton ¶
设置 btn 指向的 Button 为 弹出拍照或者相册发图 类型按钮.
func (*Button) SetAsPicSysPhotoButton ¶
设置 btn 指向的 Button 为 弹出系统拍照发图 类型按钮.
func (*Button) SetAsPicWeixinButton ¶
设置 btn 指向的 Button 为 弹出微信相册发图器 类型按钮.
func (*Button) SetAsScanCodePushButton ¶
设置 btn 指向的 Button 为 扫码推事件 类型按钮.
func (*Button) SetAsScanCodeWaitMsgButton ¶
设置 btn 指向的 Button 为 扫码推事件且弹出"消息接收中"提示框 类型按钮.
func (*Button) SetAsSubMenuButton ¶
设置 btn 指向的 Button 为 子菜单 类型按钮.
func (*Button) SetAsViewButton ¶
设置 btn 指向的 Button 为 view 类型按钮.
func (*Button) SetAsViewLimitedButton ¶
设置 btn 指向的 Button 为 跳转图文消息URL 类型按钮.
type ButtonEx ¶
type ButtonEx struct {
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Key string `json:"key,omitempty"`
URL string `json:"url,omitempty"`
MediaId string `json:"media_id,omitempty"`
Value string `json:"value,omitempty"`
NewsInfo struct {
Articles []Article `json:"list,omitempty"`
} `json:"news_info"`
SubButton struct {
Buttons []ButtonEx `json:"list,omitempty"`
} `json:"sub_button"`
}
type ClickEvent ¶
type ClickEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // 事件类型, CLICK
EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值, 与自定义菜单接口中KEY值对应
}
CLICK: 点击菜单拉取消息时的事件推送
func GetClickEvent ¶
func GetClickEvent(msg *core.MixedMsg) *ClickEvent
type LocationSelectEvent ¶
type LocationSelectEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // 事件类型, location_select
EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值, 由开发者在创建菜单时设定
SendLocationInfo *struct {
LocationX float64 `xml:"Location_X" json:"Location_X"` // 地理位置纬度
LocationY float64 `xml:"Location_Y" json:"Location_Y"` // 地理位置经度
Scale int `xml:"Scale" json:"Scale"` // 精度, 可理解为精度或者比例尺, 越精细的话 scale越高
Label string `xml:"Label" json:"Label"` // 地理位置的字符串信息
PoiName string `xml:"Poiname" json:"Poiname"` // 朋友圈POI的名字, 可能为空
} `xml:"SendLocationInfo,omitempty" json:"SendLocationInfo,omitempty"`
}
location_select: 弹出地理位置选择器的事件推送
func GetLocationSelectEvent ¶
func GetLocationSelectEvent(msg *core.MixedMsg) *LocationSelectEvent
type MatchRule ¶
type MatchRule struct {
GroupId string `json:"group_id,omitempty"`
Sex string `json:"sex,omitempty"`
Country string `json:"country,omitempty"`
Province string `json:"province,omitempty"`
City string `json:"city,omitempty"`
ClientPlatformType string `json:"client_platform_type,omitempty"`
Language string `json:"language,omitempty"`
TagId string `json:"tag_id,omitempty"`
}
type Menu ¶
type MiniProgramEvent ¶
type MiniProgramEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // 事件类型, VIEW
EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值, 设置的跳转URL
MenuId int64 `xml:"MenuId,omitempty" json:"MenuId,omitempty"` // 菜单ID,如果是个性化菜单,则可以通过这个字段,知道是哪个规则的菜单被点击了。
}
view_miniprogram: 点击菜单小程序链接时的事件推送
func GetMiniProgramEvent ¶
func GetMiniProgramEvent(msg *core.MixedMsg) *MiniProgramEvent
type PicPhotoOrAlbumEvent ¶
type PicPhotoOrAlbumEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // 事件类型, pic_photo_or_album
EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值, 由开发者在创建菜单时设定
SendPicsInfo *struct {
Count int `xml:"Count" json:"Count"`
PicList []struct {
PicMd5Sum string `xml:"PicMd5Sum" json:"PicMd5Sum"`
} `xml:"PicList>item,omitempty" json:"PicList,omitempty"`
} `xml:"SendPicsInfo,omitempty" json:"SendPicsInfo,omitempty"`
}
pic_photo_or_album: 弹出拍照或者相册发图的事件推送
func GetPicPhotoOrAlbumEvent ¶
func GetPicPhotoOrAlbumEvent(msg *core.MixedMsg) *PicPhotoOrAlbumEvent
type PicSysPhotoEvent ¶
type PicSysPhotoEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // 事件类型, pic_sysphoto
EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值, 由开发者在创建菜单时设定
SendPicsInfo *struct {
Count int `xml:"Count" json:"Count"`
PicList []struct {
PicMd5Sum string `xml:"PicMd5Sum" json:"PicMd5Sum"`
} `xml:"PicList>item,omitempty" json:"PicList,omitempty"`
} `xml:"SendPicsInfo,omitempty" json:"SendPicsInfo,omitempty"`
}
pic_sysphoto: 弹出系统拍照发图的事件推送
func GetPicSysPhotoEvent ¶
func GetPicSysPhotoEvent(msg *core.MixedMsg) *PicSysPhotoEvent
type PicWeixinEvent ¶
type PicWeixinEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // 事件类型, pic_weixin
EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值, 由开发者在创建菜单时设定
SendPicsInfo *struct {
Count int `xml:"Count" json:"Count"`
PicList []struct {
PicMd5Sum string `xml:"PicMd5Sum" json:"PicMd5Sum"`
} `xml:"PicList>item,omitempty" json:"PicList,omitempty"`
} `xml:"SendPicsInfo,omitempty" json:"SendPicsInfo,omitempty"`
}
pic_weixin: 弹出微信相册发图器的事件推送
func GetPicWeixinEvent ¶
func GetPicWeixinEvent(msg *core.MixedMsg) *PicWeixinEvent
type ScanCodePushEvent ¶
type ScanCodePushEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // 事件类型, scancode_push
EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值, 由开发者在创建菜单时设定
ScanCodeInfo *struct {
ScanType string `xml:"ScanType" json:"ScanType"` // 扫描类型, 一般是qrcode
ScanResult string `xml:"ScanResult" json:"ScanResult"` // 扫描结果, 即二维码对应的字符串信息
} `xml:"ScanCodeInfo,omitempty" json:"ScanCodeInfo,omitempty"`
}
scancode_push: 扫码推事件的事件推送
func GetScanCodePushEvent ¶
func GetScanCodePushEvent(msg *core.MixedMsg) *ScanCodePushEvent
type ScanCodeWaitMsgEvent ¶
type ScanCodeWaitMsgEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // 事件类型, scancode_waitmsg
EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值, 由开发者在创建菜单时设定
ScanCodeInfo *struct {
ScanType string `xml:"ScanType" json:"ScanType"` // 扫描类型, 一般是qrcode
ScanResult string `xml:"ScanResult" json:"ScanResult"` // 扫描结果, 即二维码对应的字符串信息
} `xml:"ScanCodeInfo,omitempty" json:"ScanCodeInfo,omitempty"`
}
scancode_waitmsg: 扫码推事件且弹出"消息接收中"提示框的事件推送
func GetScanCodeWaitMsgEvent ¶
func GetScanCodeWaitMsgEvent(msg *core.MixedMsg) *ScanCodeWaitMsgEvent
type ViewEvent ¶
type ViewEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // 事件类型, VIEW
EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值, 设置的跳转URL
MenuId int64 `xml:"MenuId,omitempty" json:"MenuId,omitempty"` // 菜单ID,如果是个性化菜单,则可以通过这个字段,知道是哪个规则的菜单被点击了。
}
VIEW: 点击菜单跳转链接时的事件推送