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 implement the custom menu bar in the development of the official account of c # Wechat

2025-02-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Editor to share with you how to implement the custom menu bar in the development of c # Wechat official account, I believe most people do not know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it!

"

This paper mainly realizes the customization of the menu bar of the official account, the Wechat public platform also has specific instructions, and there are also online debugging tools. In this paper, we realize the custom menu bar by requesting the background interface of our project. Note: when we deploy the back-end program, the port must be 80 or 443

Official development of Wechat customized menu bar: https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.htmlhttps://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.html Wechat official online debugging menu bar: https://mp.weixin.qq.com/debug/cgi-bin/apiinfo?t=index&type=%E8%87%AA%E5%AE%9A%E4% B9%89%E8%8F%9C%E5%8D%95&form=%E8%87%AA%E5%AE%9A%E4%B9%89%E8%8F%9C%E5%8D%95%E5%88%9B%E5%BB%BA%E6%8E%A5%E5%8F%A3%20/menu/creat https://mp.weixin.qq.com/debug/cgi-bin/apiinfo?t=index&type=%E8%87%AA%E5%AE%9A%E4%B9%89%E8% 8F%9C%E5%8D%95&form=%E8%87%AA%E5%AE%9A%E4%B9%89%E8%8F%9C%E5%8D%95%E5%88%9B%E5%BB%BA%E6%8E%A5%E5%8F%A3%20/menu/creat. "Okay. Let's code to implement the custom menu bar, where we need an access_token, we can just get it from the database, or global storage, which will explain in detail how to get access_token and other necessary values.

Request custom backend API http://wx.zyynet.club/WeixinAuthor/CreateMenu

/ Custom official account interface menu item / public string CreateMenu () {string url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + Config.WxConfig.Config.access_token" String data = "{\" button\ ": [{\" name\ ":\" Dotnet column\ ",\" sub_button\ ": [{\" type\ ":\" view\ ",\" name\ ":\" about me\ ",\" url\ ":\" https://blog.csdn.net/Hakim2214\"},{\"type\":\"view\",\"name\":\" Wechat Development\ " \ "url\":\ "https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html\"}]},{\"name\":\" Test\",\ "sub_button\": [{\ "type\":\ "view\",\ "name\":\ "Encyclopedia of Operations and maintenance\",\ "url\":\ "https://blog.csdn.net/Hakim2214\"},{\"type\":\"view\"," \ "name\":\ "online exam\",\ "url\":\ "http://sfmes.rjtx.net:55291/MobileApp/index.html\"}]}]}"; System.Net.HttpWebRequest httpWebRequest = (HttpWebRequest) System.Net.WebRequest.Create (url); httpWebRequest.Method = "POST"; byte [] postBytes = Encoding.UTF8.GetBytes (data); httpWebRequest.ContentType = "application/json; charset=utf-8"; / / httpWebRequest.ContentLength = Encoding.UTF8.GetByteCount (data); / / data is the json string Stream stream = httpWebRequest.GetRequestStream (); stream.Write (postBytes, 0, postBytes.Length); stream.Close () / / after sending, accept the return value var response = httpWebRequest.GetResponse (); Stream streamResponse = response.GetResponseStream (); StreamReader streamRead = new StreamReader (streamResponse); String responseString = streamRead.ReadToEnd (); return responseString;}

After a successful request, you can see the effect.

The above is all the contents of the article "how to implement a custom menu bar in the development of the official account of c # Wechat". 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.

Share To

Internet Technology

Wechat

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

12
Report