Custom menu management-custom menu creation interface

Custom menu management-custom menu creation interface

Currently, a custom menu can contain up to 3 first-level menus, and each first-level menu can contain up to 5 second-level menus. A first-level menu can contain up to 4 Chinese characters, and a second-level menu can contain up to 7 Chinese characters. The extra characters will be replaced by "...". Please note that after creating a custom menu, it will take 24 hours for the WeChat client to display it due to the WeChat client cache. It is recommended that you try to unfollow the public account and then follow it again during testing, so that you can see the effect after creation.

The custom menu interface can implement various types of buttons, as follows:

1. click: click push event

When the user clicks a click type button, the WeChat server will push a message structure of event type to the developer through the message interface (refer to the message interface guide), and bring the key value filled in by the developer in the button. The developer can interact with the user through the customized key value;

2. view: jump to URL

After the user clicks a view type button, the WeChat client will open the web URL filled in by the developer in the button, which can be combined with the web page authorization to obtain the user's basic information interface to obtain the user's basic information.

3. scancode_push: scan code push event

After the user clicks the button, the WeChat client will call up the scanning tool. After completing the scanning operation, the scanning result will be displayed (if it is a URL, the URL will be entered), and the scanning result will be transmitted to the developer, who can then send a message.

4. scancode_waitmsg: Scan the code to push the event and pop up the "Message Receiving" prompt box

After the user clicks the button, the WeChat client will call up the scanning tool. After completing the scanning operation, it will transmit the scanning result to the developer and close the scanning tool. Then a "Message Receiving" prompt box will pop up, and the user may then receive a message from the developer.

5. pic_sysphoto: pop-up system to take pictures and send pictures

After the user clicks the button, the WeChat client will call up the system camera. After completing the photo-taking operation, it will send the taken photo to the developer and push an event to the developer. At the same time, the system camera will be closed, and the developer may receive a message from the developer afterwards.

6. pic_photo_or_album: pop up to take a photo or send a photo to the album

After the user clicks the button, the WeChat client will pop up a selector for the user to choose "take a photo" or "select from the phone album". After the user makes a choice, the other two processes will be followed.

7. pic_weixin: pop up WeChat photo album sender

After the user clicks the button, the WeChat client will call up the WeChat album. After completing the selection operation, it will send the selected photos to the developer's server and push events to the developer. At the same time, the album will be closed, and the user may then receive a message from the developer.

8. location_select: Pop-up location selector

After the user clicks the button, the WeChat client will call up the location selection tool. After completing the selection operation, the selected location will be sent to the developer's server and the location selection tool will be closed. The user may then receive a message from the developer.

Please note that all events from 3 to 8 are only supported by WeChat iPhone version 5.4.1 and above, and WeChat users of Android version 5.4 and above. Users of old WeChat versions will not receive any response after clicking, and developers will not be able to receive event push normally.

Interface call request description

http request method: POST (please use https protocol) https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN

Click and view request examples

  1. {
  2. "button" :[
  3. {
  4. "type" : "click" ,
  5. "name" : "Today's Song" ,
  6. "key" : "V1001_TODAY_MUSIC"  
  7. },
  8. {
  9. "name" : "Menu" ,
  10. "sub_button" :[
  11. {
  12. "type" : "view" ,
  13. "name" : "Search" ,
  14. "url" : "http://www.soso.com/"  
  15. },
  16. {
  17. "type" : "view" ,
  18. "name" : "Video" ,
  19. "url" : "http://v.qq.com/"  
  20. },
  21. {
  22. "type" : "click" ,
  23. "name" : "Like us" ,
  24. "key" : "V1001_GOOD"  
  25. }]
  26. }]
  27. }

Request examples for other newly added button types

  1. {
  2. "button" : [
  3. {
  4. "name" : "Scan QR code" ,
  5. "sub_button" : [
  6. {
  7. "type" : "scancode_waitmsg" ,
  8. "name" : "Scan code with prompts" ,
  9. "key" : "rselfmenu_0_0" ,
  10. "sub_button" : [ ]
  11. },
  12. {
  13. "type" : "scancode_push" ,
  14. "name" : "Scan QR code push event" ,
  15. "key" : "rselfmenu_0_1" ,
  16. "sub_button" : [ ]
  17. }
  18. ]
  19. },
  20. {
  21. "name" : "Post a picture" ,
  22. "sub_button" : [
  23. {
  24. "type" : "pic_sysphoto" ,
  25. "name" : "System takes pictures and sends them" ,
  26. "key" : "rselfmenu_1_0" ,
  27. "sub_button" : [ ]
  28. },
  29. {
  30. "type" : "pic_photo_or_album" ,
  31. "name" : "Take a photo or send it to your photo album" ,
  32. "key" : "rselfmenu_1_1" ,
  33. "sub_button" : [ ]
  34. },
  35. {
  36. "type" : "pic_weixin" ,
  37. "name" : "WeChat photo album post" ,
  38. "key" : "rselfmenu_1_2" ,
  39. "sub_button" : [ ]
  40. }
  41. ]
  42. },
  43. {
  44. "name" : "Send Location" ,
  45. "type" : "location_select" ,
  46. "key" : "rselfmenu_2_0"  
  47. }
  48. ]
  49. }

Return results

The correct returned JSON data packet is as follows:

{"errcode":0,"errmsg":"ok"}

The returned JSON data packet in case of an error is as follows (the example shows the invalid menu name length):

{"errcode":40018,"errmsg":"invalid button name size"}

<<:  Status bar prompts with various effects

>>:  Data statistics interface-graphic and text analysis data interface

Recommend

How does noise, the "big devil" of sound, break people's defenses?

Have you ever been disturbed by noise? For exampl...

How to make an online promotion plan? How to formulate a promotion plan?

How to make an online promotion plan? How to form...

The most comprehensive guide to large-scale event promotion in history!

Be a long-termist and try to maximize the experie...

Inventory of classic running video types in information flow

In the current information flow industry, short v...

A user growth system that increased followers by 45 million!

Everyone knows that they should read more books a...

Market analysis of mobile advertising during the National Day holiday

The celebration of both National Day and Mid-Autu...

How should business owners choose the right promotion channels!

If we want to achieve better development, we must...

Why is no one buying products sold on Douyin live streaming?

During the 2019 Double 11 shopping festival, Taob...

Is less code cleaner?

In my eyes, clean code is simple and easy to unde...