WeChat custom menu interface

Source: Internet
Author: User

Introduction

After obtaining the credential (how to obtain the credential), the developer can use the credential to create, query, and delete user-defined menus of the public account. The custom menu interface supports the following buttons:

Click (click event): After you click the click type button, the server pushes the click event to the developer through the message interface (event type), and carries the key value filled by the developer in the button, developers can reply to a message through a custom key value. View (webpage access): After you click the view type button, the page will jump directly to the url specified by the developer.
 

After the custom menu is created, it takes 24 hours for the client to appear because of the client cache. We recommend that you try to remove the public account and follow it again during the test to see the effect after creation.

Menu Creation

Interface Description

By posting a specific struct, you can create a custom menu on the client.


Request description

Http Request Method: POSThttps: // api.weixin.qq.com/cgi-bin/menu/create? Access_token = ACCESS_TOKEN

Request example

{"Button": [{"type": "click", "name": "Today's songs", "key": "V1001_TODAY_MUSIC" },{ "type ": "view", "name": "artist profile", "url": "http://www.bkjia.com/" },{ "name": "menu", "sub_button ": [{"type": "click", "name": "hello word", "key": "V1001_HELLO_WORLD" },{ "type": "click ", "name": "like us", "key": "V1001_GOOD"}]}

Effect after creation:

Parameter description

Parameters Required? Description
Button Yes Button array, the number of buttons should be 2 ~ 3
Sub_button No Array of child buttons. The number of buttons should be 2 ~ Five
Type Yes Button type, which currently has the click type
Name Yes Button description. The name of a button cannot exceed 16 bytes, and the sub-menu cannot exceed 40 bytes.
Key Required for clicking type The KEY value of the button. It is used for message interface (event Type) Push and cannot exceed 128 bytes.

Return description

Correct Json return results:

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

Incorrect Json return result

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

Uniform return code Description

Menu Query

Interface Description

Query the currently used custom menu structure.

Request description

Http Request Method: GEThttps: // api.weixin.qq.com/cgi-bin/menu/get? Access_token = ACCESS_TOKEN

Return description

Corresponding to the creation interface, the correct Json return result: {"menu": {"button": [{"type": "click", "name": "Today's song ", "key": "V1001_TODAY_MUSIC", "sub_button": [] },{ "type": "click", "name": "", "key ": "V1001_TODAY_SINGER", "sub_button": [] },{ "name": "menu", "sub_button": [{"type": "click", "name ": "hello word", "key": "V1001_HELLO_WORLD", "sub_button": [] },{ "type": "click", "name": "like us ", "key": "V1001_GOOD", "sub_button": []}

Uniform return code Description

 

Menu Deletion

Interface Description

Cancels the currently used custom menu.

Request description

Http Request Method: GEThttps: // api.weixin.qq.com/cgi-bin/menu/delete? Access_token = ACCESS_TOKEN

Return description

Corresponding to the created interface, the correct Json return result: {"errcode": 0, "errmsg": "OK "}

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.