custom Menu Creation Interface

Source: Internet
Author: User

Custom menus help the public to enrich the interface, allowing users to better understand the function of the public number more quickly. After opening the custom menu, the public number interface:

Currently the custom menu includes up to 3 level menus, each with a maximum of 5 level two menus. A menu of up to 4 kanji, a two-level menu with a maximum of 7 Chinese characters, and the extra part will be replaced with "...". Note that after you create a custom menu, it takes 24 hours for clients to show up due to client-side caching. when you try to cancel your attention to the public account after testing, you can see the effect after the creation.

Customize the menu interface to implement several types of buttons, as follows:

  1, click: Push Event  When the user clicks the Click type button, the server pushes the message type to the developer via the message interface (refer to the Message Interface Guide), and with the key value entered by the developer in the button, The developer can interact with the user through a custom key value,  2, view: Jump URL  When the user clicks the View Type button, the client will open the URL of the Web page that the developer fills in the button, which can be combined with the Web page authorization Access user's basic information interface. Get basic user information.  3, Scancode_push: Sweep the code to push the event  when the user clicks the button, the client will be a sweep sweep tool, after the scanning operation to display the scan results (if it is a URL, will enter the URL), and will pass the results of the scan code to the developer, developers can send messages.  4, Scancode_waitmsg: Sweep the code to push the event and pop-up "message received in the" prompt box  when the user taps the button, the client will pick up the sweep tool, complete the sweep code operation, the results of the sweep code to the developer, while the sweep of scanning tools, and then pop up " Message received in the "prompt box, you may receive a message from the developer."  5, Pic_sysphoto: Pop-up system photo map  After the user taps the button, the client will call up the system camera, complete the photo operation, will send the photos taken to the developer, and push the event to the developer, while the system camera, You may then receive a message from the developer.  6, Pic_photo_or_album: pop-up photo or album map  when the user taps the button, the client pops up the selector for the user to select "Take a photo" or "Choose from a mobile album." The user chooses to go through the other two processes.  7, Pic_weixin: Pop-up album publisher  when the user taps the button, the client will pick up the album, complete the selection, send the selected photo to the developer's server, push the event to the developer, and close the album. You may then receive a message from the developer.  8, Location_select: Pop-up location selector  when the user taps the button, the client will pick up the geo-selection tool, complete the selection, send the selected location to the developer's server, and close the location selection tool. You may then receive a message from the developer. 

Please note that 3 to 8 of all events, only support iPhone5.4.1 and above, and Android5.4 above version of the user, the old version of the user will not respond to the click, the developer can not normally receive the event push.


Interface Invocation Request Description

HTTP request mode: POST (use HTTPS protocol) Https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN

Sample request for Click and view

{"     button": [     {          "type": "Click",          "name": "Today's song",          "key": "V1001_today_music"      },      {           " Name ":" Menu ",           " Sub_button ": [           {               " type ":" View ",               " name ":" Search ",               " url ":" http://www.soso.com/"            },            {               "type": "View",               "name": "Video",               "url": "http://v.qq.com/"            },            {               "type" : "Click",               "name": "Likes Us",               "key": "V1001_good"            }]       }]}

Other New button type request examples

{"button": [{"Name": "Sweep Code", "Sub_button": [{"Type":                     "Scancode_waitmsg", "name": "Sweep code with hint", "key": "Rselfmenu_0_0", "Sub_button": []}, {"Type": "Scancode_push", "Nam            E ":" Sweep code push event "," Key ":" Rselfmenu_0_1 "," Sub_button ": []} ]}, {"Name": "Send Diagram", "Sub_button": [{"Type": "P Ic_sysphoto "," Name ":" System Photo Map "," key ":" Rselfmenu_1_0 "," Sub_bu Tton ": []}, {" Type ":" Pic_photo_or_album "," name                 ":" Photo or photo album "," Key ":" Rselfmenu_1_1 "," Sub_button ": []},              {      "Type": "Pic_weixin", "Name": "Album Hair graph", "key": "Rselfmenu_1_2", "Sub_button": []}}, {"Name": "Send Location", "type": " Location_select "," Key ":" Rselfmenu_2_0 "}]}

Parameter description

Parameters whether you must Description
button Is The first-level menu array, the number should be one
Sub_button Whether Two-level menu array, the number should be a
Type Is Response Action type for menu
Name Is Menu title, no more than 16 bytes, sub-menu no more than 40 bytes
Key Click Type must Menu key value, for message interface push, no more than 128 bytes
Url The view type must Web links, users click on the menu to open the link, no more than 256 bytes


return results

The correct return JSON packet is as follows:

{"Errcode": 0, "errmsg": "OK"}

The return JSON packet On error is as follows (example is invalid menu name length):

{"Errcode": 40018, "errmsg": "Invalid button name size"}

Global Return Code description

Use Demo:

Refer to the following: http://www.5icool.org/a/201308/a2152.html

custom Menu Creation Interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.