menu

package
v0.0.0-...-7011273 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

自定义菜单接口.

Index

Constants

View Source
const (
	EventTypeClick = "click" // 点击菜单拉取消息时的事件推送
	EventTypeView  = "view"  // 点击菜单跳转链接时的事件推送

	// 请注意, 下面的事件仅支持微信iPhone5.4.1以上版本, 和Android5.4以上版本的微信用户,
	// 旧版本微信用户点击后将没有回应, 开发者也不能正常接收到事件推送.
	EventTypeScanCodePush    = "scancode_push"      // scancode_push: 扫码推事件的事件推送
	EventTypeScanCodeWaitMsg = "scancode_waitmsg"   // scancode_waitmsg: 扫码推事件且弹出“消息接收中”提示框的事件推送
	EventTypePicSysPhoto     = "pic_sysphoto"       // pic_sysphoto: 弹出系统拍照发图的事件推送
	EventTypePicPhotoOrAlbum = "pic_photo_or_album" // pic_photo_or_album: 弹出拍照或者相册发图的事件推送
	EventTypePicWeixin       = "pic_weixin"         // pic_weixin: 弹出微信相册发图器的事件推送
	EventTypeLocationSelect  = "location_select"    // location_select: 弹出地理位置选择器的事件推送
	EventTypeEnterAgent      = "enter_agent"        // enter_agent: 用户进入应用的事件推送
)
View Source
const (
	MenuButtonCountLimit    = 3 // 一级菜单最多包含 3 个按钮
	SubMenuButtonCountLimit = 5 // 二级菜单最多包含 5 个按钮
)
View Source
const (
	MenuButtonNameLenLimit    = 16 // 菜单标题不超过16个字节
	SubMenuButtonNameLenLimit = 40 // 子菜单标题不超过40个字节
)
View Source
const (
	ButtonKeyLenLimit = 128 // 菜单KEY值不能超过128字节
	ButtonURLLenLimit = 256 // 网页链接不能超过256字节
)
View Source
const (
	ButtonTypeClick = "click" // 点击推事件
	ButtonTypeView  = "view"  // 跳转URL

	// 请注意, 下面的事件, 仅支持微信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"    // 发送位置
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button struct {
	Type       string   `json:"type,omitempty"`       // 非必须; 菜单的响应动作类型
	Name       string   `json:"name,omitempty"`       // 必须;  菜单标题,不超过16个字节,子菜单不超过40个字节
	Key        string   `json:"key,omitempty"`        // 非必须; 菜单KEY值,用于消息接口推送,不超过128字节
	URL        string   `json:"url,omitempty"`        // 非必须; 网页链接,用户点击菜单可打开链接,不超过256字节
	SubButtons []Button `json:"sub_button,omitempty"` // 非必须; 二级菜单数组,个数应为1~5个
}

菜单的按钮

func (*Button) SetAsClickButton

func (btn *Button) SetAsClickButton(name, key string)

设置 btn 指向的 Button 为 click 类型按钮

func (*Button) SetAsLocationSelectButton

func (btn *Button) SetAsLocationSelectButton(name, key string)

设置 btn 指向的 Button 为 弹出地理位置选择器 类型按钮

func (*Button) SetAsPicPhotoOrAlbumButton

func (btn *Button) SetAsPicPhotoOrAlbumButton(name, key string)

设置 btn 指向的 Button 为 弹出拍照或者相册发图 类型按钮

func (*Button) SetAsPicSysPhotoButton

func (btn *Button) SetAsPicSysPhotoButton(name, key string)

设置 btn 指向的 Button 为 弹出系统拍照发图 类型按钮

func (*Button) SetAsPicWeixinButton

func (btn *Button) SetAsPicWeixinButton(name, key string)

设置 btn 指向的 Button 为 弹出微信相册发图器 类型按钮

func (*Button) SetAsScanCodePushButton

func (btn *Button) SetAsScanCodePushButton(name, key string)

设置 btn 指向的 Button 为 扫码推事件 类型按钮

func (*Button) SetAsScanCodeWaitMsgButton

func (btn *Button) SetAsScanCodeWaitMsgButton(name, key string)

设置 btn 指向的 Button 为 扫码推事件且弹出“消息接收中”提示框 类型按钮

func (*Button) SetAsSubMenuButton

func (btn *Button) SetAsSubMenuButton(name string, subButtons []Button)

设置 btn 指向的 Button 为 子菜单 类型按钮

func (*Button) SetAsViewButton

func (btn *Button) SetAsViewButton(name, url string)

设置 btn 指向的 Button 为 view 类型按钮

type ClickEvent

type ClickEvent struct {
	XMLName struct{} `xml:"xml" json:"-"`
	corp.CommonMessageHeader

	Event    string `xml:"Event"    json:"Event"`    // 事件类型,CLICK
	EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值,与自定义菜单接口中KEY值对应
}

点击菜单拉取消息的事件推送

func GetClickEvent

func GetClickEvent(msg *corp.MixedMessage) *ClickEvent

type Client

type Client struct {
	*corp.CorpClient
}

func NewClient

func NewClient(AccessTokenServer corp.AccessTokenServer, httpClient *http.Client) Client

兼容保留, 建議實際項目全局維護一個 *corp.CorpClient

func (Client) CreateMenu

func (clt Client) CreateMenu(agentId int64, menu Menu) (err error)

创建自定义菜单.

func (Client) DeleteMenu

func (clt Client) DeleteMenu(agentId int64) (err error)

删除自定义菜单

func (Client) GetMenu

func (clt Client) GetMenu(agentId int64) (menu Menu, err error)

获取自定义菜单

type EnterAgentEvent

type EnterAgentEvent struct {
	XMLName struct{} `xml:"xml" json:"-"`
	corp.CommonMessageHeader

	Event    string `xml:"Event"    json:"Event"`    // 事件类型,enter_agent
	EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值,此事件该值为空
}

enter_agent: 用户进入应用的事件推送

本事件只有在应用的回调模式中打开上报开关时上报

func GetEnterAgentEvent

func GetEnterAgentEvent(msg *corp.MixedMessage) *EnterAgentEvent

type LocationSelectEvent

type LocationSelectEvent struct {
	XMLName struct{} `xml:"xml" json:"-"`
	corp.CommonMessageHeader

	Event    string `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" json:"SendLocationInfo"` // 发送的位置信息
}

location_select: 弹出地理位置选择器的事件推送

func GetLocationSelectEvent

func GetLocationSelectEvent(msg *corp.MixedMessage) *LocationSelectEvent
type Menu struct {
	Buttons []Button `json:"button,omitempty"` // 一级菜单数组,个数应为1~3个
}

type PicPhotoOrAlbumEvent

type PicPhotoOrAlbumEvent struct {
	XMLName struct{} `xml:"xml" json:"-"`
	corp.CommonMessageHeader

	Event    string `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"` // 图片的MD5值,开发者若需要,可用于验证接收到图片
		} `xml:"PicList>item,omitempty" json:"PicList,omitempty"` // 图片列表
	} `xml:"SendPicsInfo" json:"SendPicsInfo"` // 发送的图片信息
}

pic_photo_or_album: 弹出拍照或者相册发图的事件推送

func GetPicPhotoOrAlbumEvent

func GetPicPhotoOrAlbumEvent(msg *corp.MixedMessage) *PicPhotoOrAlbumEvent

type PicSysPhotoEvent

type PicSysPhotoEvent struct {
	XMLName struct{} `xml:"xml" json:"-"`
	corp.CommonMessageHeader

	Event    string `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"` // 图片的MD5值,开发者若需要,可用于验证接收到图片
		} `xml:"PicList>item,omitempty" json:"PicList,omitempty"` // 图片列表
	} `xml:"SendPicsInfo" json:"SendPicsInfo"` // 发送的图片信息
}

pic_sysphoto: 弹出系统拍照发图的事件推送

func GetPicSysPhotoEvent

func GetPicSysPhotoEvent(msg *corp.MixedMessage) *PicSysPhotoEvent

type PicWeixinEvent

type PicWeixinEvent struct {
	XMLName struct{} `xml:"xml" json:"-"`
	corp.CommonMessageHeader

	Event    string `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"` // 图片的MD5值,开发者若需要,可用于验证接收到图片
		} `xml:"PicList>item,omitempty" json:"PicList,omitempty"` // 图片列表
	} `xml:"SendPicsInfo" json:"SendPicsInfo"` // 发送的图片信息
}

pic_weixin: 弹出微信相册发图器的事件推送

func GetPicWeixinEvent

func GetPicWeixinEvent(msg *corp.MixedMessage) *PicWeixinEvent

type ScanCodePushEvent

type ScanCodePushEvent struct {
	XMLName struct{} `xml:"xml" json:"-"`
	corp.CommonMessageHeader

	Event    string `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" json:"ScanCodeInfo"` // 扫描信息
}

scancode_push: 扫码推事件的事件推送

func GetScanCodePushEvent

func GetScanCodePushEvent(msg *corp.MixedMessage) *ScanCodePushEvent

type ScanCodeWaitMsgEvent

type ScanCodeWaitMsgEvent struct {
	XMLName struct{} `xml:"xml" json:"-"`
	corp.CommonMessageHeader

	Event    string `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" json:"ScanCodeInfo"` // 扫描信息
}

scancode_waitmsg: 扫码推事件且弹出“消息接收中”提示框的事件推送

func GetScanCodeWaitMsgEvent

func GetScanCodeWaitMsgEvent(msg *corp.MixedMessage) *ScanCodeWaitMsgEvent

type ViewEvent

type ViewEvent struct {
	XMLName struct{} `xml:"xml" json:"-"`
	corp.CommonMessageHeader

	Event    string `xml:"Event"    json:"Event"`    // 事件类型,VIEW
	EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值,设置的跳转URL
}

点击菜单跳转链接的事件推送

func GetViewEvent

func GetViewEvent(msg *corp.MixedMessage) *ViewEvent

Jump to

Keyboard shortcuts

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