Ejemplo n.º 1
0
 public ApiCommonController()
 {
     _CorpId      = DDHelper.GetCorpId();
     _CorpSecret  = DDHelper.CorpSecret();
     _AgentId     = DDHelper.GetAgentId();
     _accessToken = DDHelper.GetToken( );
 }
Ejemplo n.º 2
0
        //
        // GET: /DD/
        //public ActionResult GetUserInfo(string accessToken, string code, bool setCurrentUser = true)
        //{
        //    try
        //    {
        //        string userId = DingDingService.Instance.GetUserId(accessToken, code);
        //        string jsonString = DingDingService.Instance.GetUserDetailJson(accessToken, userId);
        //        UserDetailInfo userInfo = DingDingService.Instance.GetUserDetailFromJson(jsonString);
        //        if (setCurrentUser)
        //        {
        //            Session["AccessToken"] = accessToken;
        //            Session["CurrentUser"] = userInfo;
        //        }
        //        return Content(jsonString);
        //    }
        //    catch (Exception ex)
        //    {
        //        return Content(string.Format("{{'errcode': -1, 'errmsg':'{0}'}}", ex.Message));
        //    }
        //}


        // GET: /UserManager/
        public ActionResult Index()
        {
            string nonceStr = "HELLOWORK";//todo:随机

            ViewBag.NonceStr = nonceStr;
            string accessToken = DingDingService.GetAccessToken();

            ViewBag.AccessToken = accessToken;
            string ticket    = DingDingService.GetJsApiTicket(accessToken);
            long   timeStamp = DDHelper.GetTimeStamp();
            string url       = Request.Url.ToString();
            string signature = DingDingService.GetSign(ticket, nonceStr, timeStamp, url);

            ViewBag.JsApiTicket = ticket;
            ViewBag.Signature   = signature;
            ViewBag.NonceStr    = nonceStr;
            ViewBag.TimeStamp   = timeStamp;
            ViewBag.CorpId      = DDHelper.GetCorpId();
            ViewBag.CorpSecret  = DDHelper.CorpSecret();
            ViewBag.AgentId     = DDHelper.GetAgentId();
            return(View());
        }