微信公众号-菜单查询方法CurrentSelfMenu()报错
mm-ooto opened this issue · 6 comments
mm-ooto commented
添加的自定义菜单如下:
[
{
"type": "click",
"name": "今日歌曲",
"key": "V1001_TODAY_MUSIC"
},
{
"name": "菜单",
"sub_button": [
{
"type": "view",
"name": "搜索",
"url": "http://www.soso.com/"
},
{
"type": "click",
"name": "赞一下我们",
"key": "V1001_GOOD"
}
]
}
]
调用方法CurrentSelfMenu提示如下错误:
json: cannot unmarshal object into Go struct field Button.selfmenu_info.button.sub_button of type []*response.SubButton
CurrentSelfMenu该方法返回的json数据格式如下:
{
"is_menu_open": 1,
"selfmenu_info": {
"button": [
{
"type": "click",
"name": "今日歌曲",
"key": "V1001_TODAY_MUSIC"
},
{
"name": "菜单",
"sub_button": {
"list": [
{
"type": "view",
"name": "搜索",
"url": "http://www.soso.com/"
},
{
"type": "click",
"name": "赞一下我们",
"key": "V1001_GOOD"
}
]
}
}
]
}
}
大概看了一下好像是你们定义的selfmenu_info.sub_button类型与微信返回的不一样,最终导致unmarshal失败了,你们的结构体如下:
type SubButton struct {
List []*ButtonItem `json:"list"`
}
type Button struct {
Type string `json:"type"`
Name string `json:"name"`
Key string `json:"key"`
SubButtons []*SubButton `json:"sub_button"` // 应该是这部分导致的
}
Matrix-X commented
看起来好像是
SubButtons []*SubButton json:"sub_button" -> SubButtons *SubButton
json:"sub_button"
我刚提交了develop分之
请试着用develop分之跑通一下,可以的话,我打版本
mm-ooto commented
可以了,多谢!
2671281141
***@***.***
…------------------ 原始邮件 ------------------
发件人: "ArtisanCloud/PowerWeChat" ***@***.***>;
发送时间: 2023年7月25日(星期二) 下午4:54
***@***.***>;
***@***.******@***.***>;
主题: Re: [ArtisanCloud/PowerWeChat] 微信公众号-菜单查询方法CurrentSelfMenu()报错 (Issue #361)
看起来好像是
SubButtons []*SubButton json:"sub_button" -> SubButtons *SubButton json:"sub_button"
我刚提交了develop分之
请试着用develop分之跑通一下,可以的话,我打版本
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
Matrix-X commented
thx, I will release a tag later
Matrix-X commented
如果可以,请再试一下develop分之,我刚把我把Menu.Get 的button和CurrentSelf的SelfButton做区分了
mm-ooto commented
如果可以,请再试一下develop分之,我刚把我把Menu.Get 的button和CurrentSelf的SelfButton做区分了
我刚刚试了一下,CurrentSelfMenu和Menu.Get接口数据都可以正常返回
Matrix-X commented
pretty cool