public ActionResult JsSDK() { Common.WxHelper.JsApi_Ticket tickek = HttpContext.Application["jsapi_ticket"] as Common.WxHelper.JsApi_Ticket; //无票据或票据过期 if (tickek == null || tickek.Ticket == null || tickek.Ticket.Length == 0 || tickek.Expires < DateTime.Now) { tickek = helper.GetJsApi_Ticket(); if (string.IsNullOrEmpty(tickek.Ticket) || tickek.Expires < DateTime.Now) { return(RedirectToAction("Error", new { msg = "接口凭证不存在或已过期" })); } HttpContext.Application.Add("jsapi_ticket", tickek); } string appId = helper.AppID; string timestamp = helper.GetTimestamp(); string noncestr = helper.GetNonceStr(); string url = Request.Url.AbsoluteUri; string signature = helper.GetJsSignature(noncestr, tickek.Ticket, timestamp, url); ViewBag.appId = appId; ViewBag.timestamp = timestamp; ViewBag.noncestr = noncestr; ViewBag.signature = signature; return(View()); }
public ActionResult Menu() { Common.WxHelper.JsApi_Ticket tickek = HttpContext.Application["jsapi_ticket"] as Common.WxHelper.JsApi_Ticket; //无票据或票据过期 if (tickek == null || tickek.Ticket == null || tickek.Ticket.Length == 0 || tickek.Expires < DateTime.Now) { tickek = helper.GetJsApi_Ticket(); if (string.IsNullOrEmpty(tickek.Ticket) || tickek.Expires < DateTime.Now) { return(RedirectToAction("Error", new { msg = "接口凭证不存在或已过期" })); } HttpContext.Application.Add("jsapi_ticket", tickek); } string json = helper.GetMenu(tickek.Access_token); wxtest.Common.WxHelper.wxmenu wxmenu = jss.Deserialize <wxtest.Common.WxHelper.wxmenu>(json); wxtest.Common.WxHelper.wx_menu wx_menu = helper.ConverTowx_menu(wxmenu); ViewBag.wx_menu = wx_menu; return(View()); }
public ActionResult MenuCreate(Common.WxHelper.wx_menu m) { Common.WxHelper.JsApi_Ticket tickek = HttpContext.Application["jsapi_ticket"] as Common.WxHelper.JsApi_Ticket; //无票据或票据过期 if (tickek == null || tickek.Ticket == null || tickek.Ticket.Length == 0 || tickek.Expires < DateTime.Now) { tickek = helper.GetJsApi_Ticket(); if (string.IsNullOrEmpty(tickek.Ticket) || tickek.Expires < DateTime.Now) { return(RedirectToAction("Error", new { msg = "接口凭证不存在或已过期" })); } HttpContext.Application.Add("jsapi_ticket", tickek); } wxtest.Common.WxHelper.wxmenu wxmenu = helper.ConverTowxmenu(m); //var menu = GetMenu(wxmenu); //string json = jss.Serialize(menu); string json = jss.Serialize(wxmenu.menu); bool result = helper.CreateMenu(tickek.Access_token, json); ViewBag.result = result ? "操作成功" : "操作失败"; return(View()); }