public IActionResult GetDDConfig() { //获取Token var corpId = DingTalkConfig.CorpId; var corpSecret = DingTalkConfig.CorpSecret; var token = DingTalkHelper.GetAccessToken(corpId, corpSecret); //HttpContext.Session.SetString("Token", _token); //获取部门 //string _depart = DingTalkHelper.GetDepartmentsList(_token); //获取JsApiTicket var ticket = DingTalkHelper.GetJsApiTicket(token); //HttpContext.Session.SetString("Ticket", _ticket); //获取url string url = "http://10.0.1.46:5000/";//"http://" + HttpContext.Request.Host.ToString(); //生成config信息 var _ddconfig = DingTalkHelper.GetDingdingConfig(url, ticket); Dictionary <string, string> dic = new Dictionary <string, string>(); if (_ddconfig.Code == ResultModel.ResultCode.Success) { dic = (Dictionary <string, string>)_ddconfig.Data; ViewBag.AgentId = dic["agentId"]; ViewBag.Timestamp = dic["timeStamp"]; ViewBag.Noncestr = dic["nonceStr"]; ViewBag.Signature = dic["signature"]; return(Ok(new { token, ticket, corpId, url, agentId = dic["agentId"], timeStamp = dic["timeStamp"], nonceStr = dic["nonceStr"], signature = dic["signature"] })); } return(Ok()); }
//[HandlerAjaxOnly] public ActionResult GetDingTalkAppConfigJson() { string url = Request.Url.PathAndQuery; DingTalkAppConfig config = ding.GetAppConfig("1"); if (config != null) { config.TimeStamp = DingTalkHelper.GetTimeStamp(); config.NonceStr = "metec"; string jsapi_ticket = DingTalkHelper.GetJsApiTicket(config.AccessToken); config.Signature = DingTalkHelper.GetAccessSignature(config.NonceStr, config.TimeStamp.ToString(), jsapi_ticket, url); } return(Content(config.ToJson())); }
private object GetDingTalkCorpConfig(string url) { DingTalkCorpConfig config = ding.GetAccessToken(); if (config != null) { config.TimeStamp = DingTalkHelper.GetTimeStamp(); config.NonceStr = DingTalkHelper.GuidTo16String(); string jsapi_ticket = DingTalkHelper.GetJsApiTicket(config.AccessToken); config.url = url; config.jsapi_ticket = jsapi_ticket; config.Signature = DingTalkHelper.GetAccessSignature(config.NonceStr, config.TimeStamp.ToString(), jsapi_ticket, url); } return(config); }
//[HandlerAjaxOnly] public ActionResult GetDingTalkCorpConfigJson(string url) { DingTalkCorpConfig config = ding.GetAccessToken(); if (config != null) { config.TimeStamp = DingTalkHelper.GetTimeStamp(); config.NonceStr = DingTalkHelper.GuidTo16String(); string jsapi_ticket = DingTalkHelper.GetJsApiTicket(config.AccessToken); config.url = url; config.jsapi_ticket = jsapi_ticket; config.Signature = DingTalkHelper.GetAccessSignature(config.NonceStr, config.TimeStamp.ToString(), jsapi_ticket, url); } return(Content(config.ToJson())); }