How to add custom menu via http request?

零下一度
Release: 2017-05-27 14:20:19
Original
2057 people have browsed it

Overview

If you choose to develop a development version for WeChat, you cannot use the Custom menu tool in the function, and you need to add it manually using code. This article mainly introduces how to add a custom menu through http request.

Principles and Tools

If you want to add your own menu, you need to send a create menu message to a URL on WeChat. Just send once and your changes will be saved.

WeChat provides a debugging tool that can directly send the edited information to the corresponding URL. The address of the tool is here

Create Menu

First get the AccessToken. Children's shoes who don't know how to operate can refer to here

After getting the token, fill it in after the "access_token" of the tool, and then enter a format of json# in the body input box below. ##Text:

{
     "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"
            }]
       }]
 }
Copy after login

There are many types of menu buttons added, and there are only 3 or 4 commonly used ones. For more usage, please refer to the official documentation here.

Send to add

After filling in, click the button below to submit to complete the addition. It is said that there is a 24-hour delay, but it took effect immediately after I sent it. In addition, I also encountered an error report with a return code of 40001. After a while, nothing was changed, but the submission was successful. It is probably a small bug somewhere: )

[Related recommendations]

1.

Share the example tutorial of mini program development and calling interface

2.

The example code of mini program red envelope interface development

3.

Detailed explanation of mini program development using Underscore.js

4.

WeChat public account development tutorial Part 14 - Custom menu creation and menu event response

5.

Simple example code for small program development

The above is the detailed content of How to add custom menu via http request?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!