In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to use Java to achieve Wechat official account custom menu", the content is easy to understand, clear, hope to help you solve your doubts, now let the editor lead you to study and learn "how to use Java to achieve Wechat official account custom menu" this article.
The details are as follows:
When developing official accounts, you may need to add events to some custom menus, such as clicking on a menu and then the server pushes information to the user.
We can also use the web debugging tool provided by Wechat to generate menus directly, but we need to consider whether it will affect users.
Note: using code to customize menu events, manually added menus will become invalid! Use it carefully!
Official document
If necessary, the httpClientUtil utility class can be obtained from the previous Wechat official account to obtain access_token.
Public class WechatDIYMenuTest {public static void main (String [] args) {String accessToken = "15_A0pP-hwxjv3DCQbQmk9Gl99aIvjieSO6FStnoNyt78_S_Souv9RmMWRu9ndzlFJT4iD1e3iLXNGvxP2AB4aZ0k1" + "pK76Sp9DYMVLJZThKcsRCIJtFOw3qfGuM5d0GTDdAAAMZJ"; JSONObject jsonObject = new JSONObject (); JSONArray jsonArray = new JSONArray (); / / first-level menu JSONObject menu1 = new JSONObject (); menu1.put ("type", "click"); menu1.put ("name", "menu 1"); menu1.put ("key", "key_1") JsonArray.add (menu1); / / first-level menu JSONObject menu2 = new JSONObject (); menu2.put ("name", "menu 2"); JSONArray jsonArray2 = new JSONArray (); / / second-level menu JSONObject menu3 = new JSONObject (); menu3.put ("type", "click"); menu3.put ("name", "menu 3"); menu3.put ("key", "key_3") JsonArray2.add (menu3); menu2.put ("sub_button", jsonArray2); jsonArray.add (menu2); JSONObject menu4 = new JSONObject (); menu4.put ("type", "click"); menu4.put ("name", "menu 4"); menu4.put ("key", "key_4"); jsonArray.add (menu4); jsonObject.put ("button", jsonArray) String url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + accessToken; String result = HttpClientUtil.doPostJson (url, jsonObject.toJSONString ()); System.out.println (result);}} these are all the contents of the article" how to use Java to implement the custom menu of Wechat official account ". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.