/// <summary> /// 获取用户最后1个标签; /// </summary> /// <param name="openId"></param> public string GetUserLastTag(string openId) { var tagList = UserTagApi.Get(AccessToken); if (tagList.errcode != 0 || tagList.tags == null || tagList.tags.Count == 0) { return(null); } var result = UserTagApi.UserTagList(AccessToken, openId); if (result.errcode != 0 || result.tagid_list == null) { return(null); } var lastTagId = result.tagid_list.LastOrDefault(); if (lastTagId == 0) { return(null); } var tag = tagList.tags.Where(a => a.id == lastTagId).FirstOrDefault(); if (tag == null) { return(null); } return(tag.name); }
public ActionResult MenuManager() { AccessTokenContainer.Register("wx4df7108464fb86f1", "46515264f29685ba478ea93d44919ed5"); var accessToken = AccessTokenContainer.GetAccessToken(AppId); var aa = UserTagApi.Get(accessToken); ButtonGroup bg = new ButtonGroup(); //单击 bg.button.Add(new SingleClickButton() { name = "单击测试", key = "OneClick", type = ButtonType.click.ToString(),//默认已经设为此类型,这里只作为演示 }); //二级菜单 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跳转" }); bg.button.Add(subButton); var result = CommonApi.CreateMenu(accessToken, bg); return(View()); }
/// <summary> /// 根据标签名称获取标签的Id; /// </summary> /// <param name="tagName"></param> /// <returns></returns> public int?GetTagId(string tagName) { var tagList = UserTagApi.Get(AccessToken); if (tagList.errcode != 0 || tagList.tags == null || tagList.tags.Count == 0) { return(null); } var tag = tagList.tags.FirstOrDefault(a => a.name == tagName); if (tag == null) { return(null); } return(tag.id); }