1.先获取access_token (工具:微信公众平台接口调试工具

登录公众号测试号,获取appid,appsecret,然后使用调试工具,选择接口类型和接口列表

参数填写上已有的appid,appsecret,固定参grant_type

body:{
    "grant_type": "client_credential", 
    "appid": "", 
    "secret": ""
}

2.用获取的access_token ,选择菜单接口

body:{
       //单独的菜单
		"button": [
			{
				"type": "view",
				"name": "test1",
				"url": "https://www.baidu.com/"
			},
			{
				"type": "view",
				"name": "test2",
				"url": "https://www.baidu.com/"
			}
		],
        
	}

//包含子菜单
body:{
       {
		"type": "view",
		"name": "test1",
		"url": "https://www.baidu.com/"
		},
        {
           "name":"菜单",
           "sub_button":[
           {	
               "type":"view",
               "name":"搜索",
               "url":"http://www.soso.com/"
            },
            {
                 "type":"miniprogram",
                 "name":"wxa",
                 "url":"http://mp.weixin.qq.com",
                 "appid":"wx286b93c14bbf93aa",
                 "pagepath":"pages/lunar/index"
             },
            {
               "type":"click",
               "name":"赞一下我们",
               "key":"V1001_GOOD"
            }]      
        }

}

3.关于菜单中含有key

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐