Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use API to create official account Custom menu

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to use API to create official account custom menu". In daily operation, I believe many people have doubts about how to use API to create official account custom menu. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the questions of "how to use API to create official account custom menu". Next, please follow the editor to study!

In the technical documentation of Wechat official account platform, click "Custom menu":

The format of the HTTPpost message that needs to maintain parameters to create a custom menu is given in the document:

Going back to my example, I use postman to send this HTTP post request:

This is the content of my HTTP post message:

{"button": [{"name": "UI5", "sub_button": [{"type": "view", "name": "Jerry List", "url": "http://wechatjerry.herokuapp.com/ui5"},{"type":" click "," name ":" Other UI5 application "," key ":" dataQuery "}]}}

The above json format message defines a first-level menu, and the label text is UI5. Two secondary menus (sub_button) with types view and click, respectively.

The view type binds a HTML page to the secondary menu, click and jump to this page. The html page bound to my example is http://wechatjerry.herokuapp.com/ui5. The menu type click is easy to understand. After clicking, the Wechat platform will send an event to your official account Wechat server. You need to deal with this time in your Wechat server. The event type is specified by the parameter key. The type of my example above is dataQuery, which can be specified at will.

The pseudo code for the custom secondary menu of Wechat with the response type of click is as follows:

App.route ('/') .post (function (req,res) {req.on ("end", function () {var msgType = formattedValue (getXMLNodeValue ('MsgType', content)); if (msgType = = "event") {var eventKey = formattedValue (getXMLNodeValue (' EventKey', content) If (eventKey = = "dataQuery") {/ / respond to the click} of Wechat custom secondary menu); at this point, the study on "how to use API to create official account custom menu" is over, hoping to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report