超碰中文网,91久久精品日日躁夜夜躁欧美,一区二区三区精品道,一区二区国产在线观看,亚洲精品中文字幕乱码一区二区,天天看片高清影视在线观看,久久99精品久久久久蜜桃,久久成人影视

VPS參考測評推薦
專注分享VPS主機優惠信息
衡天云優惠活動
熱網互聯2026年促銷活動
hostkvm優惠促銷活動
zji優惠促銷活動
QQGNET優惠促銷活動
QQGNET優惠促銷活動

分享微信微信官方賬號開發自定義菜單的示例教程(微信微信官方賬號中的自定義菜單怎么做)

主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情!
我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作

歡迎留言,轉發,

項目源代碼參考地址點擊我點擊我--歡迎開始。

自定義菜單有兩種實現方式:1 .編輯模式2。開發模式。

編輯模式很簡單,就不贅述了。......

開發模式1下自定義菜單的實現。利用微信公眾平臺2的接口調試工具實現。使用官方提供的接口實現。

前期準備添加插件

分享微信微信官方賬號開發自定義菜單的示例教程(微信微信官方賬號中的自定義菜單怎么做)

K8WTIEI86W9W5XERD`MRD{6.png

利用微信公眾平臺接口調試工具實現分享微信微信官方賬號開發自定義菜單的示例教程(微信微信官方賬號中的自定義菜單怎么做)

自定義菜單-界面調試工具。png

正如您所看到的,兩個參數是必需的,并且都是access_token主體所必需的。

有人想問,這兩個參數怎么獲???

Body實際上是一個生成菜單的JSON對象。官方提供一個栗子供參考。

{ & quot按鈕& quot:

自定義菜單-以獲取access_token.png

利用官方提供的接口,我們可以在Jfinal-weixin中創建、查詢和刪除封裝菜單以及創建、查詢和刪除個性化菜單,并測試個性化菜單的匹配結果。

分享微信微信官方賬號開發自定義菜單的示例教程(微信微信官方賬號中的自定義菜單怎么做)

自定義菜單-菜單封裝界面。png

那么問題來了,包裝好了怎么用?以下是提供封裝的接口

//查詢自定義菜單公共靜態API結果get menu(){ string JSON result = httputils . get(get menu+accesstokenapi . getaccessstokenstr());返回新的API result(JSON result);}//創建自定義菜單公共靜態API結果創建菜單(string JSON str){ string JSON result = httputils . post(Create menu+accesstokenapi . getaccesstokenstr()、JSON str);返回新的API result(JSON result);}//刪除自定義菜單公共靜態API結果Delete menu(){ string JSON result = httputils . get(deletemenuurl+accesstokenapi . getaccesstokenstr());返回新的API result(JSON result);}//創建個性化定制菜單公共靜態API結果添加條件(String JSON STR){ String JSON Result = Httputils。post(AddConditionalURL+AccessorTokenAPI。GetAccessorTokenstr(),JSON STR);返回新的API result(JSON result);}//刪除個性化定制菜單公共靜態API結果del conditional(string menuid){ hashmap params = new hashmap();params . put(& quot;menuid & quot,menuid);string URL = delConditionalUrl+accesstokenapi . getaccessstokenstr();string JSON result = httputils . post(URL,JSON utils . to JSON(params));返回新的API result(JSON result);}//測試個性化菜單匹配結果公共靜態API結果try match(string userid){ hashmap params = new hashmap();params . put(& quot;用戶標識& quot,userId);string URL = tryMatchUrl+accesstokenapi . getaccessstokenstr();string JSON result = httputils . post(URL,JSON utils . to JSON(params));返回新的API result(JSON result);}公共靜態API result getCurrentSelfMenuInfo(){ String JSON result = httputils . get(getCurrentSelfMenuInfoUrl+accesstokenapi . getaccesstokenstr());返回新的API result(JSON result);}開源項目weixin_guide中的com . javen . weixin . menu . menu manager類中提供了詳細的演示。

public static void main(String[]args){//將菜單對象轉換為json字符串String JSON Menu = JSON Kit。ToJSON (gettestmenu())。tostring();system . out . println(JSON menu);API config AC = new API config();//要配置微信API相關常量,請使用自己的AC . setappid(& quot;wx 614 c 453 E0 D1 DCD 12 & quot;);AC . setappsecret(& quot;19 a02e 4927d 346484 fc 70327970457 f 9 & quot;);//AC . setappid(prop kit . get(& quot;appId & quot));//AC . setappsecret(prop kit . get(& quot;appSecret&quot));API config kit . setthreadlocalapiconfig(AC);//創建菜單API結果API result = menuapi。創建菜單(JSON菜單);system . out . println(API result . get JSON());}可以看到main方法中調用了MenuApi.createMenu(jsonMenu)。jsonMenu從何而來?

實際上,自定義菜單的實體對象在這里被轉化為JSON。

string JSON menu = JSON kit . to JSON(gettest menu())。toString();

menu/* * *組裝菜單數據的包* * @ return */private靜態菜單gettest menu(){ clickbutton BTN 11 = new click button();btn11.setName(&quot微信相冊發圖”);BTN 11 . settype(& quot;pic _ weixin & quot);BTN 11 . setkey(& quot;rselfmenu _ 1 _ 1 & quot);click button BTN 12 = new click button();btn12.setName在相冊里拍照或發圖”);BTN 12 . settype(& quot;圖片_照片_或_相冊& quot);BTN 12 . setkey(& quot;rselfmenu _ 1 _ 2 & quot);;click button BTN 13 = new click button();btn13.setName系統拍照發圖”);BTN 13 . settype(& quot;pic _ sysphoto & quot);BTN 13 . setkey(& quot;rselfmenu _ 1 _ 3 & quot);click button BTN 21 = new click button();BTN 21 . setname(& quot;帶提示的掃碼”);BTN 21 . settype(& quot;scancode _ waitmsg & quot);BTN 21 . setkey(& quot;rselfmenu _ 2 _ 1 & quot);;click button BTN 22 = new click button();btn22.setName(&quot掃碼推送事件”);BTN 22 . settype(& quot;scancode _ push & quot);BTN 22 . setkey(& quot;rselfmenu _ 2 _ 2 & quot);;view button BTN 23 = new view button();btn23.setName(&quot我的設備”);BTN 23 . settype(& quot;查看& quot);BTN 23 . seturl(& quot;https://HW . weixin . QQ . com/device ctrl/panel/device -list . html?appid = wx 614 c 453 E0 D1 DCD 12 & quot;);view button BTN 31 = new view button();btn31.setName微社區”);BTN 31 . settype(& quot;查看& quot);BTN 31 . seturl(& quot;http://whsf.tunnel.mobi/whsf/msg/wsq");click button BTN 32 = new click button();btn32.setName發送位置”);BTN 32 . settype(& quot;位置選擇& quot);BTN 32 . setkey(& quot;rselfmenu _ 3 _ 2 & quot);//http://tencent://message/?uin=572839485。Site=在線咨詢&;Menu =是//http://wpa.qq.com/msgrd?v = 3 & ampuin=572839485。site = qq & ampmenu = yes view button BTN 33 = new view button();btn33.setName在線咨詢”);BTN 33 . settype(& quot;查看& quot);BTN 33 . seturl(& quot;http://wpa.qq.com/msgrd? v = 3 & amp;uin=572839485。site = qq & ampmenu = yes & quot);view button BTN 34 = new view button();btn34.setName我的博客& quot);BTN 34 . settype(& quot;查看& quot);BTN 34 . seturl(& quot;http://www.cnblogs.com/zyw-205520");click button BTN 35 = new click button();btn35.setName點擊事件”);settype(& quot;單擊& quot);setkey(& quot;rselfmenu _ 3 _ 5 & quot);ComButton main BTN 1 = new ComButton();main BTN 1 . setname(& quot;發個圖”);main BTN 1 . set sub _ Button(new Button[]{ BTN 11,btn12,BTN 13 });ComButton main BTN 2 = new ComButton();main BTN 2 . setname(& quot;掃碼”);main BTN 2 . set sub _ Button(new Button[]{ BTN 21,btn22,BTN 23 });ComButton main BTN 3 = new ComButton();main BTN 3 . setname(& quot;個人中心”);main BTN 3 . set sub _ Button(new Button[]{ BTN 31,btn32,btn33,btn34,BTN 35 });/* * *這是目前微信官方賬號xiaoqrobot的菜單結構,每個一級菜單都有一個二級菜單項< br & gt* *當一級菜單下沒有二級菜單時,如何定義一個菜單?& ltbr & gt*例如,第三個一級菜單項不是“更多體驗”,而是直接“幽默笑話”,因此菜單應定義如下:

生成菜單的JSON:{ " button & quot;:[{ & quot;sub _ button & quot:[{ & quot;名稱& quot:& quot微信相冊發圖”,& quot鍵入& quot:& quotpic _ weixin & quot,& quotkey & quot:& quotrselfmenu _ 1 _ 1 & quot},{ & quot名稱& quot:& quot在相冊中拍攝照片或發送圖片”,& quot鍵入& quot:& quot圖片_照片_或_相冊& quot,& quotkey & quot:& quotrselfmenu _ 1 _ 2 & quot},{ & quot名稱& quot:& quot系統拍照并發送圖片”鍵入& quot:& quotpic _ sysphoto & quot,& quotkey & quot:& quotrselfmenu _ 1 _ 3 & quot}],& quot名稱& quot:& quot發送圖片”鍵入& quot:null}、{ & quotsub _ button & quot:[{ & quot;名稱& quot:& quot掃碼提示“,& quot鍵入& quot:& quotscancode _ waitmsg & quot,& quotkey & quot:& quotrselfmenu _ 2 _ 1 & quot},{ & quot名稱& quot:& quot掃碼推送事件”鍵入& quot:& quotscancode _ push & quot,& quotkey & quot:& quotrselfmenu _ 2 _ 2 & quot},{ & quot名稱& quot:& quot我的設備”鍵入& quot:& quot查看& quot,& quoturl & quot:& quothttps://HW . weixin . QQ . com/device ctrl/panel/device -list . html?appid = wx 614 c 453 E0 D1 DCD 12 & quot;}],& quot名稱& quot:& quot掃碼“,& quot鍵入& quot:null}、{ & quotsub _ button & quot:[{ & quot;名稱& quot:& quot微社區",& quot鍵入& quot:& quot查看& quot,& quoturl & quot:& quothttp://whsf.tunnel.mobi/whsf/msg/wsq" }、{ & quot名稱& quot:& quot發送位置“,& quot鍵入& quot:& quot位置選擇& quot,& quotkey & quot:& quotrselfmenu _ 3 _ 2 & quot},{ & quot名稱& quot:& quot在線咨詢”,& quot鍵入& quot:& quot查看& quot,& quoturl & quot:& quothttp://wpa.qq.com/msgrd? v = 3 & amp;uin=572839485。site = qq & ampmenu = yes & quot},{ & quot名稱& quot:& quot我的博客鍵入& quot:& quot查看& quot,& quoturl & quot:& quothttp://www.cnblogs.com/zyw-205520" }、{ & quot名稱& quot:& quot單擊事件”鍵入& quot:& quot單擊& quot,& quotkey & quot:& quotrselfmenu _ 3 _ 5 & quot}],& quot名稱& quot:& quot個人中心”鍵入& quot:null}],& quot匹配規則& quot:null}響應的狀態:{ & quot錯誤代碼& quot:0,& quoterrmsg & quot:& quot好的& quot}以上是生成自定義菜單的全過程。

[相關建議]

1.下載微信微信官方賬號平臺源代碼。

2.微智創T+微信機器人源代碼

3.微信網王v3.4.5高級商業版微信魔方源代碼

這幾篇文章你可能也喜歡:

  • 暫無相關推薦文章

本文由主機參考刊發,轉載請注明:分享微信微信官方賬號開發自定義菜單的示例教程(微信微信官方賬號中的自定義菜單怎么做) http://m.k2270.com/114362.html

【騰訊云】領8888元采購禮包,搶爆款云服務器 每月 9元起,個人開發者加享折上折!
打賞
轉載請注明原文鏈接:主機參考 » 分享微信微信官方賬號開發自定義菜單的示例教程(微信微信官方賬號中的自定義菜單怎么做)
主機參考僅做資料收集,不對商家任何信息及交易做信用擔保,購買前請注意風險,有交易糾紛請自行解決!請查閱:特別聲明

評論 搶沙發

評論前必須登錄!