C # menu development on WeChat public platform

Source: Internet
Author: User

C # public platform menu Development
Menu creation format:

{"Button": [{"type": "click", "name": "Today's songs", "key": "V1001_TODAY_MUSIC" },{ "name ": "menu", "sub_button": [{"type": "view", "name": "Search", "url": "http://www.soso.com /"}, {"type": "view", "name": "video", "url": "http://v.qq.com/" },{ "type": "click", "name ": "like us", "key": "V1001_GOOD"}]}

 

If it is not the first time you create a menu, you need to delete an existing menu before creating the menu, delete the menu request address is: https://api.weixin.qq.com/cgi-bin/menu/delete? Access_token = value. Place the obtained ACCESS_TOKEN value into the link address to delete the existing menu. Example: menu creation clip: string postString = "{\" button \ ": [{\" name \ ": \" courier \ ", \" sub_button \": [{\ "type \": \ "click \", \ "name \": \ "revision announcement \", \ "key \": \ "RevisionNotice \"}, {\ "type \": \ "view \", \ "name \": \ "Spring read books \", \ "url \": \ "http://ah.10086.cn/new/s/ydty/ctdhsxscd \"}]}, {\ "name \": \ "I want to share \", \ "sub_button \": [{\ "type \": \ "click \", \ "name \": \ "· \", \ "key \": \ "bookRanking \" },{ \ "type \": \ "click \", \ "name \": \ "\", \ "key \": \ "musicRanking \ "},{ \" Type \ ": \" click \ ", \" name \ ": \" play interesting games \ ", \" key \": \ "gameRanking \"}] },{\ "name \": \ "personal center \", \ "sub_button \": [{\ "type \": \ "click \", \ "name \": \ "authentication \", \ "key \": \ "BDClick \" },{ \ "type \": \ "click \", \ "name \": \ "Point redemption \", \ "key \": \ "OnExchange \" },{ \ "type \": \ "click \", \ "name \": \ "points rule description \", \ "key \": \ "IntegralRule \"}]} "; // circle menu byte [] postData = Encoding. UTF8.GetBytes (postString); // encoding, especially for Chinese characters. You must first check the encoding method of the captured webpage: string url = "h Ttps: // api.weixin.qq.com/cgi-bin/menu/create? Access_token = token "; // enter the obtained ACCESS_TOKEN value into the link to create the menu WebClient webClient = new WebClient (); webClient. headers. add ("Content-Type", "application/x-www-form-urlencoded"); // header required for POST, if you change the GET method, you can remove this sentence byte [] responseData = webClient. uploadData (url, "POST", postData); // returns the response stream string srcString = Encoding. UTF8.GetString (responseData); // decodes Response. write (srcString );

Related Article

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.