日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
一日一技:微信開發(fā)自定義菜單

概述

成都創(chuàng)新互聯(lián)公司專注于任縣企業(yè)網(wǎng)站建設,響應式網(wǎng)站,商城開發(fā)。任縣網(wǎng)站建設公司,為任縣等地區(qū)提供建站服務。全流程定制設計,專業(yè)設計,全程項目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務

自定義菜單能夠幫助公眾號豐富界面,讓用戶更好更快地理解公眾號的功能。

文檔定義

接口調用請求說明

http請求方式:POST(請使用https協(xié)議) https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN

click和view的請求示例

 
 
 
  1.      "button":[ 
  2.      {   
  3.           "type":"click", 
  4.           "name":"今日歌曲", 
  5.           "key":"V1001_TODAY_MUSIC" 
  6.       }, 
  7.       { 
  8.            "name":"菜單", 
  9.            "sub_button":[ 
  10.            {   
  11.                "type":"view", 
  12.                "name":"搜索", 
  13.                "url":"http://www.soso.com/" 
  14.             }, 
  15.             { 
  16.                  "type":"miniprogram", 
  17.                  "name":"wxa", 
  18.                  "url":"http://mp.weixin.qq.com", 
  19.                  "appid":"wx286b93c14bbf93aa", 
  20.                  "pagepath":"pages/lunar/index" 
  21.              }, 
  22.             { 
  23.                "type":"click", 
  24.                "name":"贊一下我們", 
  25.                "key":"V1001_GOOD" 
  26.             }] 
  27.        }] 
  28.  } 

實現(xiàn)方式

1、定義菜單json文檔

 
 
 
  1.   "button": [ 
  2.  
  3.     { 
  4.       "name": "運營提升", 
  5.       "sub_button": [ 
  6.         { 
  7.           "type": "view", 
  8.           "name": "免費試用", 
  9.           "url": "https://acc.bqool.cn/freetrial" 
  10.         }, 
  11.         { 
  12.           "type": "view", 
  13.           "name": "新 AI調價", 
  14.           "url": "https://www.bqool.cn/products/repricing-central/" 
  15.         }, 
  16.         { 
  17.           "type": "view", 
  18.           "name": "熱 賣家酷", 
  19.           "url": "https://www.bqool.cn/bigcentral/" 
  20.         }, 
  21.  
  22.         { 
  23.           "type": "view", 
  24.           "name": "熱 選品酷", 
  25.           "url": "https://www.bqool.cn/products/chrome-extension/" 
  26.         }, 
  27.         { 
  28.           "type": "view", 
  29.           "name": "更多產品..", 
  30.           "url": "https://www.bqool.cn/" 
  31.         } 
  32.       ] 
  33.     }, 
  34.     { 
  35.       "name": "酷仔部落", 
  36.       "sub_button": [ 
  37.         { 
  38.           "type": "view", 
  39.           "name": "限時福利", 
  40.           "url": "https://mp.weixin.qq.com/mp/video?__biz=MzIzMjc1NTY3MQ==&mid=100007240&sn=04973c15f924fc78a78fec50cd75d706&vid=wxv_1500216251938308102&idx=1&vidsn=a27a0d1d9503802f9f9095534d4d2507&fromid=1&xtrack=1&scene=0&subscene=10000&clicktime=1600054770&enterid=1600054770#wechat_redirect" 
  41.         }, 
  42.         { 
  43.           "type": "view", 
  44.           "name": "成功案例", 
  45.           "url": "https://www.bqool.cn/user-stories/" 
  46.         }, 
  47.         { 
  48.           "type": "view", 
  49.           "name": "教學視頻", 
  50.           "url": "https://www.bqool.cn/video-tutorial/" 
  51.         }, 
  52.         { 
  53.           "type": "view", 
  54.           "name": "部落文章", 
  55.           "url": "https://mp.weixin.qq.com/mp/homepage?__biz=MzIzMjc1NTY3MQ==&hid=1&sn=db4536a338f0e128ce2e5db089f381e1&scene=18" 
  56.         } 
  57.  
  58.       ] 
  59.     }, 
  60.     { 
  61.       "name": "權益中心", 
  62.       "sub_button": [ 
  63.         { 
  64.           "type": "view", 
  65.           "name": "簽到抽獎", 
  66.           "url": "http://u135069.s.24hwpro.com/web/game/game_id/1220189859" 
  67.         }, 
  68.         { 
  69.           "type": "view", 
  70.           "name": "商務合作", 
  71.           "url": "https://h5.eqxiul.com/ls/EyOfmUXk" 
  72.         }, 
  73.         { 
  74.           "type": "view", 
  75.           "name": "電商服務", 
  76.           "url": "https://www.bqool.cn/seller-services/" 
  77.         }, 
  78.         { 
  79.           "type": "view", 
  80.           "name": "聯(lián)系酷仔", 
  81.           "url": "https://admin.qidian.qq.com/template/blue/mp/menu/qr-code-jump.html?linkType=0&env=ol&kfuin=2852161981&fid=95&key=71d05b6c5e0a545f0be22ec831f9d7af&cate=1&type=16&ftype=1&_type=wpa&qidian=true" 
  82.         } 
  83.       ] 
  84.     } 
  85.   ] 

2、讀取json文件

 
 
 
  1. ///  
  2.         /// 自定義菜單 
  3.         ///  
  4.         ///  
  5.         ///  
  6.         ///  
  7.         [BQoolException] 
  8.         [HttpPost] 
  9.         public ApiResult CustomMenus(string CustomMenusPwd) 
  10.         { 
  11.             if (!string.IsNullOrWhiteSpace(CustomMenusPwd) && CustomMenusPwd.Trim() == MvcTools.GetAppSetting("WeixinCustomMenus")) 
  12.             { 
  13.                 CustomMenusParam param = new CustomMenusParam() { Account = "sys", UpdateUser = "sys" }; 
  14.                 param.Jsonstr = WeiXinHelper.ReadAccess(HttpRuntime.AppDomainAppPath.ToString() + "/App_Data/WeChat/Custom_Menus.json"); 
  15.                 ApiResult result = _weChatAlertsService.CustomMenus(param, AppId, Appsecret); 
  16.                 return result; 
  17.             } 
  18.             else 
  19.             { 
  20.                 return new ApiResult() { Success = false, Code = ApiResultCode.InvalidError, ErrorMessage = ApiResultCode.ErrorMessages[ApiResultCode.InvalidError] }; 
  21.             } 
  22.         } 

3、post提交數(shù)據(jù)到微信服務器

 
 
 
  1. private static Tuple CustomMenus(string AppId, string Appsecret, string jsonstr, bool isResh) 
  2.         { 
  3.             var accessToken = TryGetAccessToken(AppId, Appsecret, isResh); 
  4.             string url = APIConfig.Custom_Menus(accessToken); 
  5.             string str = APIConfig.CreatePostHttpResponse(url, jsonstr); 
  6.             _logger.Debug("自定義菜單\r\n" + "輸入:" + url + "\r\n" + jsonstr + "\r\n輸出:" + str); 
  7.             return new Tuple(JsonConvert.DeserializeObject(str), url, jsonstr); 
  8.         } 
 
 
 
  1. public static string WEIXIN_URL = "https://api.weixin.qq.com/"; 
  2.  
  3.         public static string Custom_Menus(string token) 
  4.         { 
  5.             return String.Format(WEIXIN_URL + "cgi-bin/menu/create?access_token={0}", token); 
  6.         } 

備注:一般情況下,不管是創(chuàng)建或者修改菜單,使用 "cgi-bin/menu/create這個接口即可。


分享名稱:一日一技:微信開發(fā)自定義菜單
標題網(wǎng)址:http://www.5511xx.com/article/djohjdo.html