using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Senparc.Weixin.Entities; using Senparc.Weixin.Exceptions; using Senparc.Weixin.Helpers.Extensions; using Senparc.Weixin.MP.CommonAPIs; using Senparc.Weixin.MP.Entities; using Senparc.Weixin.MP.Entities.Menu; using Senparc.Weixin.MP.Containers; namespace NetWing.BPM.Admin.weixin { public partial class menu : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { <!--获取微信app id 与appSecret--> string appId = NetWing.Common.ConfigHelper.GetValue("AppID"); string appSecret= NetWing.Common.ConfigHelper.GetValue("AppSecret"); <!--为accessToken进行赋值--> var accessToken = AccessTokenContainer.TryGetAccessToken(appId, appSecret); <!--把赋值过的accessToken进行变量赋值--> var r = CommonApi.DeleteMenu(accessToken); //第二步:组织菜单内容 ButtonGroup bg = new ButtonGroup(); //单击 只是一个菜单 //bg.button.Add(new SingleClickButton() //{ // name = "单击测试", // key = "OneClick", // type = "click",//默认已经设为此类型,这里只作为演示 //}); var onesubButton = new SubButton() { name = "客户管理" }; onesubButton.sub_button.Add(new SingleViewButton() { url = "http://wzsh.ynicp.com/weixin/login.aspx", name = "客户管理" }); onesubButton.sub_button.Add(new SingleViewButton() { url = "http://wzsh.ynicp.com/weixin/daikuansq.aspx", name = "贷款申请" }); onesubButton.sub_button.Add(new SingleViewButton() { url = "http://wzsh.ynicp.com/weixin/usercenter.aspx", name = "会员中心" }); ////二级菜单 //var subButton = new SubButton() //{ // name = "二级菜单" //}; //subButton.sub_button.Add(new SingleClickButton() //{ // key = "SubClickRoot_Text", // name = "返回文本" //}); //subButton.sub_button.Add(new SingleClickButton() //{ // key = "SubClickRoot_News", // name = "返回图文" //}); //subButton.sub_button.Add(new SingleClickButton() //{ // key = "SubClickRoot_Music", // name = "返回音乐" //}); //subButton.sub_button.Add(new SingleViewButton() //{ // url = "http://weixin.senparc.com", // name = "Url跳转" //}); //二级菜单 var subButton = new SubButton() { name = "金融服务" }; subButton.sub_button.Add(new SingleViewButton() { url = "http://wzsh.ynicp.com/weixin/product.aspx", name = "产品介绍" }); subButton.sub_button.Add(new SingleViewButton() { url = "http://wzsh.ynicp.com/weixin/daili.aspx", name = "合作加盟" }); var treesubButton = new SubButton() { name = "关于纵恒" }; treesubButton.sub_button.Add(new SingleViewButton() { url = "http://wzsh.ynicp.com/weixin/about.aspx", name = "关于纵恒" }); bg.button.Add(onesubButton); bg.button.Add(subButton); bg.button.Add(treesubButton); //第三步:提交到微信服务器 var result = CommonApi.CreateMenu(accessToken, bg); } } }
Copyright © 2004-2024 Ynicp.com 版权所有 法律顾问:建纬(昆明)律师事务所 昆明市网翼通科技有限公司 滇ICP备08002592号-4