Summary of wechat development and learning (4) - user defined menu (2) - user defined menu query interface

Keywords: JSON encoding

Custom menu query interface

After using the interface to create a custom menu, developers can also use the interface to query the structure of the custom menu. In addition, please note that after the personalized menu is set, the default menu and all personalized menu information can be obtained by using this customized menu query interface.

Request explanation

http Request method: GET
https://api.weixin.qq.com/cgi-bin/menu/get?access_token=ACCESS_TOKEN

Return to description (when there is no personalized menu)

Corresponding to the creation interface, the correct Json returns the result:
{
    "menu": {
        "button": [
            {
                "type": "click", 
                "name": "today's songs", 
                "key": "V1001_TODAY_MUSIC", 
                "sub_button": [ ]
            }, 
            {
                "type": "click", 
                "name": "singer profile", 
                "key": "V1001_TODAY_SINGER", 
                "sub_button": [ ]
            }, 
            {
                "name": "menu", 
                "sub_button": [
                    {
                        "type": "view", 
                        "name": "search", 
                        "url": "http://www.soso.com/", 
                        "sub_button": [ ]
                    }, 
                    {
                        "type": "view", 
                        "name": "video", 
                        "url": "http://v.qq.com/", 
                        "sub_button": [ ]
                    }, 
                    {
                        "type": "click", 
                        "name": "like us", 
                        "key": "V1001_GOOD", 
                        "sub_button": [ ]
                    }
                ]
            }
        ]
    }
}

Return to description (with personalized menu)

{
    "menu": {
        "button": [
            {
                "type": "click", 
                "name": "Today's songs", 
                "key": "V1001_TODAY_MUSIC", 
                "sub_button": [ ]
            }
        ], 
        "menuid": 208396938
    }, 
    "conditionalmenu": [
        {
            "button": [
                {
                    "type": "click", 
                    "name": "Today's songs", 
                    "key": "V1001_TODAY_MUSIC", 
                    "sub_button": [ ]
                }, 
                {
                    "name": "menu", 
                    "sub_button": [
                        {
                            "type": "view", 
                            "name": "search", 
                            "url": "http://www.soso.com/", 
                            "sub_button": [ ]
                        }, 
                        {
                            "type": "view", 
                            "name": "video", 
                            "url": "http://v.qq.com/", 
                            "sub_button": [ ]
                        }, 
                        {
                            "type": "click", 
                            "name": "Like us", 
                            "key": "V1001_GOOD", 
                            "sub_button": [ ]
                        }
                    ]
                }
            ], 
            "matchrule": {
                "group_id": 2, 
                "sex": 1, 
                "country": "China", 
                "province": "Guangdong", 
                "city": "Guangzhou", 
                "client_platform_type": 2
            }, 
            "menuid": 208396993
        }
    ]
}

Note: menu is the default menu, and conditionalmenu is the personalized menu list. For field description, please refer to the description on the interface page of personalized menu.

Return result

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": "Menu title 1", 
                "sub_button": [
                    {
                        "type": "click", 
                        "name": "Click type menu 1", 
                        "key": "1", 
                        "sub_button": [ ]
                    }
                ]
            }, 
            {
                "name": "Menu title 2", 
                "sub_button": [
                    {
                        "type": "click", 
                        "name": "Click type menu 1", 
                        "key": "11", 
                        "sub_button": [ ]
                    }, 
                    {
                        "type": "view", 
                        "name": "Click on page type 1", 
                        "url": "http://www.baidu.com", 
                        "sub_button": [ ]
                    }
                ]
            }, 
            {
                "name": "Menu title 3", 
                "sub_button": [
                    {
                        "type": "scancode_push", 
                        "name": "Code scanning push event", 
                        "key": "scancode_push", 
                        "sub_button": [ ]
                    }, 
                    {
                        "type": "scancode_waitmsg", 
                        "name": "Scan code with prompt", 
                        "key": "scancode_waitmsg", 
                        "sub_button": [ ]
                    }, 
                    {
                        "type": "pic_sysphoto", 
                        "name": "System photo sending", 
                        "key": "pic_sysphoto", 
                        "sub_button": [ ]
                    }, 
                    {
                        "type": "pic_photo_or_album", 
                        "name": "Photo taking or photo album distribution", 
                        "key": "pic_photo_or_album", 
                        "sub_button": [ ]
                    }, 
                    {
                        "type": "pic_weixin", 
                        "name": "Wechat photo album sending", 
                        "key": "pic_weixin", 
                        "sub_button": [ ]
                    }
                ]
            }
        ]
    }
}

Posted by wstran on Sat, 21 Dec 2019 12:20:06 -0800