自定义菜单
读取(查询)已设置菜单
OfficialAccountApp.Menu.Get(https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Querying_Custom_Menus.html)
获取当前菜单
OfficialAccountApp.Menu.CurrentSelfMenu()
添加菜单
添加普通菜单
OfficialAccountApp.Menu.Create(ctx, &request.RequestMenuCreate{
Buttons: []*request.Button{
{
Type: "click",
Name: "今日歌曲",
Key: "V1001_TODAY_MUSIC",
},
{
Name: "Menu1",
SubButtons: []request.SubButton{
{
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",
},
},
},
},
})
添加个性化菜单
OfficialAccountApp.Menu.CreateConditional(ctx, &request.RequestMenuCreate{
Buttons: []*request.Button{
{
Type: "click",
Name: "个性化菜单",
Key: "V1001_TODAY_MUSIC",
},
},
}, &request.RequestMatchRule{
Sex: "1",
Country: "中国",
Province: "广东",
City: "广州",
ClientPlatformType: "2",
})
删除菜单
OfficialAccountApp.Menu.Delete()
menuID := 1
OfficialAccountApp.Menu.DeleteConditional(menuID)
测试个性化菜单
OfficialAccountApp.Menu.TryMatch("[userID]")
使用示例
当前内容版权归 ArtisanCloud 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ArtisanCloud .