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 );