示例#1
0
        /// <summary>
        /// 设置自定义菜单
        /// </summary>
        public static void SetMenu(this IWeixinAccess svc, WXMenu[] btns)
        {
            // 删除菜单
            var url = string.Format(menu_del_url, svc.AccessToken);
            HttpUtils.JsonQuery<WXResult>(url);

            // 创建菜单
            url = string.Format(menu_create_url, svc.AccessToken);
            var result = HttpUtils.JsonQuery<WXResult>(url, new { button = btns });
            if (!result.IsSucceed)
                throw new WXException(result, "SetMenu", url);
        }
示例#2
0
        /// <summary>
        /// 处理Restful请求
        /// </summary>
        void ProcessRestRequest(HttpListenerRequest req, HttpListenerResponse resp)
        {
            Contract.Assert(req.Url.Segments.Length > 2);

            var svcName = req.Url.Segments[2].Trim('/').ToLower();
            switch (svcName)
            {
                case "ticket":
                    {
                        var ticket = this.JsTicket();
                        resp.SendPlainText(ticket);
                    }
                    break;
                case "menu":
                    {
                        var menus = new WXMenu[]
                        {
                            new WXMenu() { Type="view", Url="http://www.ultragis.com:8001/mob/guide.html", Name="服务号" },
                            new WXMenu() { Type="view", Url="http://www.ultragis.com:8001/mob/employee_adviser.html", Name="企业号" }
                        };
                        this.SetMenu(menus);
                    }
                    break;
            }
        }