Пример #1
0
        public ActionResult jssignature()
        {
            string   url = Request["url"].TryToString();
            TimeSpan ts  = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);

            string timestamp = Convert.ToInt64(ts.TotalSeconds).ToString();
            //随机数
            var noncestr = url.MD5() + Utils.GetRandom(10000, 99999);

            var jsapi_ticket = WeChatAccessTokenAPI.Getjsapi_ticket();

            ClassLoger.Info("jsapi_ticket", jsapi_ticket);
            ClassLoger.Info("url", url);
            if (url.IsNull())
            {
                url = Request.Url.ToString();
            }
            string data      = string.Format("jsapi_ticket={0}&noncestr={1}&timestamp={2}&url={3}", jsapi_ticket, noncestr, timestamp, url);
            string signature = Utils.SHA1(data);

            return(Json(new { timestamp = timestamp, noncestr = noncestr, appid = SystemSet.Serviceappid, signature = signature }, JsonRequestBehavior.AllowGet));
        }