public JsonResult DoCreateCreateConditionalMPMenu(int appId, string group_id, string menuStr) { group_id = group_id.Trim(); menuStr = menuStr.Trim(); if (appId > 0 && !string.IsNullOrEmpty(group_id) && !string.IsNullOrEmpty(menuStr)) { try { _log.Debug("{0} create conditional menu for {1}", appId, group_id); var menuMatchRule = new Weixin.MP.Entities.Menu.MenuMatchRule() { tag_id = group_id, //group_id = group_id, }; var result = _menuService.CreateConditionalMenu(appId, menuStr, menuMatchRule); if (result.errcode == ReturnCode.请求成功) { return(SuccessNotification("操作成功")); } else { return(ErrorNotification("操作失败: " + result.errmsg)); } } catch (Exception ex) { return(ErrorNotification(ex)); } } return(null); }
public CreateMenuConditionalResult CreateConditionalMenu(int appId, string menuJsonStr, Weixin.MP.Entities.Menu.MenuMatchRule menuMatchRule) { var config = WeChatCommonService.GetWeChatConfigByID(appId); if (config != null && config.IsCorp.HasValue && !config.IsCorp.Value) { var menu = Innocellence.Weixin.MP.CommonAPIs.CommonApi.GetMenuFromJson(menuJsonStr); if (menu != null) { Weixin.MP.Entities.Menu.ConditionalButtonGroup conditonalBtnGroup = new Weixin.MP.Entities.Menu.ConditionalButtonGroup() { button = menu.menu.button, matchrule = menuMatchRule, }; var result = Innocellence.Weixin.MP.CommonAPIs.CommonApi.CreateMenuConditional(config.WeixinCorpId, config.WeixinCorpSecret, conditonalBtnGroup); return(result); } } throw new Exception(string.Format("{0} 的配置错误, 请联系管理员.", appId)); }