怎么在微信公眾號(hào)平臺(tái)中實(shí)現(xiàn)接口開(kāi)發(fā)?相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站制作、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿(mǎn)足客戶(hù)于互聯(lián)網(wǎng)時(shí)代的古冶網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!官方菜單功能介紹
請(qǐng)求接口:https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN
新增菜單管理類(lèi)
public class MenuFirstLayerModel { public string name { get; set; } public Listsub_button { get; set; } } public class MenuTwoLayerModel { public string type { get; set; } public string name { get; set; } public string key { get; set; } public string url { get; set; } } public class WXMenu { public List button { get; set; } public string Create() { try { var requestUri = string.Format(@"https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}", WeCharBase.AccessToken); return WeCharBase.Post(requestUri, new StringContent(JsonConvert.SerializeObject(new { button = button }))); } catch (Exception ex) { return ex.Message; } } }
新增控制器MenuController.cs
public ActionResult ViewMenu() { return View(); } public ActionResult CreateMenu() { var wxMenu = new WXMenu() { button = new List() { new MenuFirstLayerModel() { name="掃碼", sub_button = new List () { new MenuTwoLayerModel() { type = "scancode_waitmsg", name = "掃碼帶提示", key = "rselfmenu_0_0" }, new MenuTwoLayerModel() { type = "scancode_push", name = "掃碼推事件", key = "rselfmenu_0_1" } }, }, new MenuFirstLayerModel() { name = "發(fā)圖", sub_button = new List () { new MenuTwoLayerModel() { type = "pic_sysphoto", name = "系統(tǒng)拍照發(fā)圖", key = "rselfmenu_1_0" }, new MenuTwoLayerModel() { type = "pic_photo_or_album", name = "拍照或者相冊(cè)發(fā)圖", key = "rselfmenu_1_1" }, new MenuTwoLayerModel() { type = "pic_weixin", name = "微信相冊(cè)發(fā)圖", key = "rselfmenu_1_2" } } }, new MenuFirstLayerModel() { name = "其他", sub_button = new List () { new MenuTwoLayerModel() { type = "location_select", name = "發(fā)送位置", key = "rselfmenu_2_0" }, new MenuTwoLayerModel() { type = "click", name = "今日歌曲", key = "V1001_TODAY_MUSIC" }, new MenuTwoLayerModel() { type = "view", name = "百度", url = "http://www.baidu.com" } } } } }; return Content(wxMenu.Create()); }
新增視圖ViewMenu.cshtml
菜單創(chuàng)建
|
看完上述內(nèi)容,你們掌握怎么在微信公眾號(hào)平臺(tái)中實(shí)現(xiàn)接口開(kāi)發(fā)的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!