1.最近微信公众号开发了菜单关联小程序功能,实现代码如下
/***自定义菜单工具类*@authorwhy**/publicclassMenuUtil{privatestaticLoggerloggerLogger.getLogger(MenuUtil.class);//日志//创建菜单接口地址publicfinalstaticStringmenu_create_url"https://api.weixin.qq.com/cgi-bin/menu/create?access_tokenACCESS_TOKEN";/***创建菜单*@parammenu菜单实例*@paramaccessToken凭证*@returntrue成功false失败*/publicstaticbooleancreateMenu(Menumenu,StringaccessToken){booleanresultfalse;Stringurlmenu_create_url.replace("ACCESS_TOKEN",accessToken);//将菜单对象转换成JSON字符串StringjsonMenuJSONObject.fromObject(menu).toString();//发起post请求创建菜单JSONObjectjsonObjectWeixinUtil.httpRequest(url,"POST",jsonMenu);if(null!jsonObject){interrorCodejsonObject.getInt("errcode");StringerrorMsgjsonObject.getString("errmsg");System.out.println(""+errorCode+""+errorMsg);if(0errorCode){resulttrue;}else{resultfalse;logger.error("创建菜单失败errorCode:{"+errorCode+"}errorMsg:{"+errorMsg+"}");System.out.println(errorCode+""+errorMsg);}}returnresult;}}/***类名称:ToXcx.java*类描述:小程序菜单实体类*作者:why*时间:2017年4月21日*/publicclassToXcxextendsButton{privateStringtype;//类型privateStringname;//菜单名称privateStringurl;//不支持小程序跳转地址privateStringappid;//小程序appidprivateStringpagepath;//小程序页面路径publicStringgetType(){returntype;}publicvoidsetType(Stringtype){this.typetype;}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.namename;}publicStringgetUrl(){returnurl;}publicvoidsetUrl(Stringurl){this.urlurl;}publicStringgetAppid(){returnappid;}publicvoidsetAppid(Stringappid){this.appidappid;}publicStringgetPagepath(){returnpagepath;}publicvoidsetPagepath(Stringpagepath){this.pagepathpagepath;}}创建菜单ToXcxxcxBtn1newToXcx();xcxBtn1.setName("我要寄件");xcxBtn1.setType("miniprogram");xcxBtn1.setUrl("");xcxBtn1.setAppid("");xcxBtn1.setPagepath("pages/send/send");调用MenuUtil.createMenu(菜单json,token);
Java微信公众号菜单关联小程序-小程序怎么放到公众号菜单里-公众号菜单链接小程序
浏览量:1342
时间:
来源:王慧永
版权声明
即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。
最新资讯
-

小程序制作平台选型踩坑记录:2026年五大主流方案横向对比
2026 年微信小程序月活达 10.7 亿、覆盖 108 个行业,本次横向对比即速应用、乔拓云、凡科、有赞、微盟五大主流平台,分三阶段给出选型结论,核心聚焦成本、扩展性、运营能力三大维度。 -

即速应用,赋能企业玩转微信小程序智慧经营
作为国内领军的智慧商业经营服务商,即速应用始终秉承“让每个企业都拥有自己的智慧店铺”的愿景,持续赋能更多企业玩转智慧经营。即速应用旗下拥有“小程序搭建工具-即速应用”、“私域流量专家-即客云”等产品,帮助商家打通互联网全生态营销闭环。 -

即客云2.0重磅更新,让微信小程序运营更简单!
即客云作为一款基于企业微信的第三方工具,现从多维度提供超过30种功能,自上线以来,已服务多家企业,受到一致好评。近期,我们根据客户反馈和市场调研正式推出升级版 即客云2.0!更新了私域运营SOP,群日历功能,批量拓客,客户雷达,消息推送,个人欢迎语,帮助企业更好运用企业微信;同时提升了社群运营工作标准化,提升运营效率,帮助企业实现客户增长,玩转私域流量。










