版权声明:本文为博主原创文章,请尊重原创,未经博主允许禁止转载,保留追究权 https://blog.csdn.net/qq_29914837/article/details/82928977
自定义菜单查询接口
使用接口创建自定义菜单后,开发者还可使用接口查询自定义菜单的结构。另外请注意,在设置了个性化菜单后,使用本自定义菜单查询接口可以获取默认菜单和全部个性化菜单信息。
请求说明
http请求方式:GET
https://api.weixin.qq.com/cgi-bin/menu/get?access_token=ACCESS_TOKEN
返回说明(无个性化菜单时)
对应创建接口,正确的Json返回结果:
{
"menu": {
"button": [
{
"type": "click",
"name": "今日歌曲",
"key": "V1001_TODAY_MUSIC",
"sub_button": [ ]
},
{
"type": "click",
"name": "歌手简介",
"key": "V1001_TODAY_SINGER",
"sub_button": [ ]
},
{
"name": "菜单",
"sub_button": [
{
"type": "view",
"name": "搜索",
"url": "http://www.soso.com/",
"sub_button": [ ]
},
{
"type": "view",
"name": "视频",
"url": "http://v.qq.com/",
"sub_button": [ ]
},
{
"type": "click",
"name": "赞一下我们",
"key": "V1001_GOOD",
"sub_button": [ ]
}
]
}
]
}
}
返回说明(有个性化菜单时)
{
"menu": {
"button": [
{
"type": "click",
"name": "今日歌曲",
"key": "V1001_TODAY_MUSIC",
"sub_button": [ ]
}
],
"menuid": 208396938
},
"conditionalmenu": [
{
"button": [
{
"type": "click",
"name": "今日歌曲",
"key": "V1001_TODAY_MUSIC",
"sub_button": [ ]
},
{
"name": "菜单",
"sub_button": [
{
"type": "view",
"name": "搜索",
"url": "http://www.soso.com/",
"sub_button": [ ]
},
{
"type": "view",
"name": "视频",
"url": "http://v.qq.com/",
"sub_button": [ ]
},
{
"type": "click",
"name": "赞一下我们",
"key": "V1001_GOOD",
"sub_button": [ ]
}
]
}
],
"matchrule": {
"group_id": 2,
"sex": 1,
"country": "中国",
"province": "广东",
"city": "广州",
"client_platform_type": 2
},
"menuid": 208396993
}
]
}
注:menu为默认菜单,conditionalmenu为个性化菜单列表。字段说明请见个性化菜单接口页的说明。
返回结果
200 OK
Connection: keep-alive
Date: Tue, 02 Oct 2018 14:12:09 GMT
Content-Type: application/json; encoding=utf-8
Content-Length: 841
{
"menu": {
"button": [
{
"name": "菜单标题1",
"sub_button": [
{
"type": "click",
"name": "点击类型菜单1",
"key": "1",
"sub_button": [ ]
}
]
},
{
"name": "菜单标题2",
"sub_button": [
{
"type": "click",
"name": "点击类型菜单1",
"key": "11",
"sub_button": [ ]
},
{
"type": "view",
"name": "点击网页类型1",
"url": "http://www.baidu.com",
"sub_button": [ ]
}
]
},
{
"name": "菜单标题3",
"sub_button": [
{
"type": "scancode_push",
"name": "扫码推事件",
"key": "scancode_push",
"sub_button": [ ]
},
{
"type": "scancode_waitmsg",
"name": "扫码带提示",
"key": "scancode_waitmsg",
"sub_button": [ ]
},
{
"type": "pic_sysphoto",
"name": "系统拍照发图",
"key": "pic_sysphoto",
"sub_button": [ ]
},
{
"type": "pic_photo_or_album",
"name": "拍照或者相册发图",
"key": "pic_photo_or_album",
"sub_button": [ ]
},
{
"type": "pic_weixin",
"name": "微信相册发图",
"key": "pic_weixin",
"sub_button": [ ]
}
]
}
]
}
}