コード例 #1
0
ファイル: MenuApi.cs プロジェクト: jiajiawei/WebMVCSolution
        /// <summary>
        /// 创建菜单
        /// </summary>
        /// <param name="accessToken">调用接口凭证</param>
        /// <param name="menuJson">菜单对象</param>
        /// <returns></returns>
        public CommonResult CreateMenu(string accessToken, MenuJson menuJson)
        {
            var url = string.Format("https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}", accessToken);
            string postData = menuJson.ToJson();

            return Helper.GetExecuteResult(url, postData);
        }
コード例 #2
0
        private void btnCreateMenu_Click(object sender, EventArgs e)
        {
            MenuInfo productInfo = new MenuInfo("软件产品", new MenuInfo[] {
                new MenuInfo("病人资料管理系统", ButtonType.click, "patient"),
                new MenuInfo("客户关系管理系统", ButtonType.click, "crm"),
                new MenuInfo("酒店管理系统", ButtonType.click, "hotel"),
                new MenuInfo("送水管理系统", ButtonType.click, "water")
            });

            MenuInfo frameworkInfo = new MenuInfo("框架产品", new MenuInfo[] {
                new MenuInfo("Win开发框架", ButtonType.click, "win"),
                new MenuInfo("WCF开发框架", ButtonType.click, "wcf"),
                new MenuInfo("混合式框架", ButtonType.click, "mix"),
                new MenuInfo("Web开发框架", ButtonType.click, "web"),
                new MenuInfo("代码生成工具", ButtonType.click, "database2sharp")
            });

            MenuInfo relatedInfo = new MenuInfo("相关链接", new MenuInfo[] {
                new MenuInfo("公司介绍", ButtonType.click, "Event_Company"),
                new MenuInfo("官方网站", ButtonType.view, "http://www.iqidi.com"),
                new MenuInfo("提点建议", ButtonType.click, "Event_Suggestion"),
                new MenuInfo("联系客服", ButtonType.click, "Event_Contact"),
                new MenuInfo("发邮件", ButtonType.view, "http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=S31yfX15fn8LOjplKCQm")
            });

            MenuJson menuJson = new MenuJson();
            menuJson.button.AddRange(new MenuInfo[] { productInfo, frameworkInfo, relatedInfo });

            //Console.WriteLine(menuJson.ToJson());

            //if (MessageUtil.ShowYesNoAndWarning("您确认要创建菜单吗") == System.Windows.Forms.DialogResult.Yes)
            //{
            //    IMenuApi menuBLL = new MenuApi();
            //    CommonResult result = menuBLL.CreateMenu(token, menuJson);
            //    Console.WriteLine("创建菜单:" + (result.Success ? "成功" : "失败:" + result.ErrorMessage));
            //}
        }