Personalized menu interface
Personalized menu interface
In order to help public accounts achieve flexible business operations, the WeChat public platform has added a personalized menu interface. Developers can use this interface to allow public accounts to Different user groups see different custom menus. This interface is open to certified subscription accounts and certified service accounts.
Developers can set the menu that users see through the following conditions:
1、用户标签(开发者的业务需求可以借助用户标签来完成) 2、性别 3、手机操作系统 4、地区(用户在微信客户端设置的地区) 5、语言(用户在微信客户端设置的语言)
Personalized menu interface description:
1、个性化菜单要求用户的微信客户端版本在iPhone6.2.2,Android 6.2.4以上,暂时不支持其他版本微信 2、菜单的刷新策略是,在用户进入公众号会话页或公众号profile页时,如果发现上一次拉取菜单的请求在5分钟以前,就会拉取一下菜单,如果菜单有更新,就会刷新客户端的菜单。测试时可以尝试取消关注公众账号后再次关注,则可以看到创建后的效果 3、普通公众号的个性化菜单的新增接口每日限制次数为2000次,删除接口也是2000次,测试个性化菜单匹配结果接口为20000次 4、出于安全考虑,一个公众号的所有个性化菜单,最多只能设置为跳转到3个域名下的链接 5、创建个性化菜单之前必须先创建默认菜单(默认菜单是指使用普通自定义菜单创建接口创建的菜单)。如果删除默认菜单,个性化菜单也会全部删除 6、个性化菜单接口支持用户标签,请开发者注意,当用户身上的标签超过1个时,以最后打上的标签为匹配
Personality Description of personalized menu matching rules:
个性化菜单的更新是会被覆盖的。 例如公众号先后发布了默认菜单,个性化菜单1,个性化菜单2,个性化菜单3。那么当用户进入公众号页面时,将从个性化菜单3开始匹配,如果个性化菜单3匹配成功,则直接返回个性化菜单3,否则继续尝试匹配个性化菜单2,直到成功匹配到一个菜单。 根据上述匹配规则,为了避免菜单生效时间的混淆,决定不予提供个性化菜单编辑API,开发者需要更新菜单时,需将完整配置重新发布一轮。
Create personalized menu
http request method: POST ( Please use https protocol)
https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=ACCESS_TOKEN
Request example
{ "button":[ { "type":"click", "name":"今日歌曲", "key":"V1001_TODAY_MUSIC" }, { "name":"菜单", "sub_button":[ { "type":"view", "name":"搜索", "url":"http://www.soso.com/" }, { "type":"view", "name":"视频", "url":"http://v.qq.com/" }, { "type":"click", "name":"赞一下我们", "key":"V1001_GOOD" }] }], "matchrule":{ "tag_id":"2", "sex":"1", "country":"中国", "province":"广东", "city":"广州", "client_platform_type":"2", "language":"zh_CN" } }
Parameter description
Parameter | Is it necessary | Description |
---|---|---|
button | Yes | First-level menu array, the number should be 1~3 |
sub_button | No | Second-level menu array, the number Should be 1~5 |
type | is the response action type of the | menu |
name | is the | menu title, no more than 16 bytes, and the submenu no more than 40 bytes |
key | Click and other click types must | Menu KEY value, used for message interface push, no more than 128 bytes |
url | View type must | Web page link, the user can click the menu to open the link, no more than 1024 bytes |
media_id | media_id type and view_limited type must | The legal media_id |
matchrule | returned by calling the new permanent material interface is | menu matching rule |
tag_id | No | The id of the user tag can be obtained through the user tag management interface |
sex | No | Gender: Male (1) Female (2), if not filled in, no matching will be performed |
client_platform_type | No | Client version, Currently, only the system model is specific: IOS(1), Android(2), Others(3), if not filled in, no matching will be done |
country | No | Country information is the region set by the user in WeChat. For details, please refer to the region information table |
province | No | Province information , is the region set by the user in WeChat. For details, please refer to the region information table |
city | No | City information, is the city information set by the user in WeChat The set region, please refer to the region information table |
language | No | Language information is the language set by the user in WeChat. For details, please refer to the language table: 1. Simplified Chinese "zh_CN" 2. Traditional Chinese TW "zh_TW" 3. Traditional Chinese HK "zh_HK" 4. English "en" 5. Indonesian "id" 6. Malay "ms" 7. Spanish "es" 8. South Korea "ko" 9. Italian "it " 10. Japanese "ja" 11. Polish "pl" 12. Portuguese "pt" 13. Russian "ru" 14. Thai "th" 15. Vietnamese "vi" 16. Arabic "ar" 17. North India "hi " 18. Hebrew "he" 19. Turkish "tr" 20. German "de" 21. French "fr" |
matchrule has a total of six fields, all of which can be empty, but not all of them can be empty. At least one matching information must be non-empty. The regional information composed of country, province, and city will be verified in the order of country, province, and city, and must comply with the content of the regional information table. The regional information is verified from large to small. The small one does not need to be filled in. That is, if the province information is filled in, the national information must also be filled in and matches. The city information does not need to be filled in. For example, "Guangzhou City, Guangdong Province, China" and "Guangdong Province, China" are both legal geographical information, but "Guangzhou City, China" is illegal because the city information is filled in but the province information is not filled in. Pleaseclick to download for the regional information table.
Return results
The returned JSON data packet when correct is as follows. For the return code when incorrect, please see the interface return code description.
{ "menuid":"208379533" }
Delete personalized menu
http request method: POST (please use https protocol)
https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token=ACCESS_TOKEN
Request example
{ "menuid":"208379533" }
menuid is the menu id, which can be obtained through the custom menu query interface.
The returned JSON data packet when correct is as follows. For the return code when incorrect, please see the interface return code description. :
{"errcode":0,"errmsg":"ok"}
Test personalized menu matching results
http request method: POST (please use https protocol)
https://api.weixin.qq.com/cgi-bin/menu/trymatch?access_token=ACCESS_TOKEN
Request example
{ "user_id":"weixin" }
user_id can be the fan's OpenID or the fan's WeChat ID.
Return result This interface will return the menu configuration, the example is as follows:
{ "button": [ { "type": "view", "name": "tx", "url": "http://www.qq.com/", "sub_button": [ ] }, { "type": "view", "name": "tx", "url": "http://www.qq.com/", "sub_button": [ ] }, { "type": "view", "name": "tx", "url": "http://www.qq.com/", "sub_button": [ ] } ] }
For the return code in case of error, please see the interface return code description.
Query personalized menu
Use the normal custom menu query interface to obtain the default menu and all personalized menu information, please see Customization Description of the menu query interface.
Delete all menus
Use the common custom menu deletion interface to delete all custom menus (including default menus and all personalized menus) , please see the description of the custom menu deletion interface.