zoukankan      html  css  js  c++  java
  • wx jssdk

        public static Dictionary<string,string> jsstr(string url)
        {
            //noncestr
            string noncestr=jssdk.GenerateRandom(16);
            
            //timestamp
            TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            string timestamp = Convert.ToInt64(ts.TotalSeconds).ToString();
    
            //jsapi_ticket 尝试本地读取
            //{"ticket":"~~~","expires_in":1432785380}
            //^^json格式
       
            int i=0;
            string path=System.Web.HttpContext.Current.Server.MapPath("~/App_Data/jsapi_ticket.txt");
            read_jspai: string json=txtdata.txtread(path);
            string jsapi_ticket=jssdk.rejson(json,"ticket");
            string expires_in=jssdk.rejson(json,"expires_in");
            //jsapi_ticket 是否超时
            if(int.Parse(expires_in)<int.Parse(timestamp))
            {
                //只会调一次接口,避免重复
                if(i==0)
                {
                    //获取最新 jsapi_ticket_get  --AppID--AppSecret
                    string info=jssdk.jsapi_ticket_get("!!!!","@@@@");
                    if(info=="ok")
                    {
                        i=1;
                        goto read_jspai;
                    }
            
                }
            }
            string signaturestr = "jsapi_ticket=" + jsapi_ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + url;
            signaturestr=jssdk.SHA1(signaturestr);
    
    
            Dictionary<string, string> mydic = new Dictionary<string, string>();
            mydic.Add("appId","wx5b7c682cca621df2");
            mydic.Add("timestamp",timestamp);
            mydic.Add("nonceStr",noncestr);
            mydic.Add("signature", signaturestr);
    
            return mydic;
    
        }
  • 相关阅读:
    nfs共享目录及sersync实时同步
    rsync备份
    MySQL基础操作
    源码包安装MySQL
    二进制安装MySQL
    Centos6防火墙-iptables版
    linux系统mongdb基础(1)
    linux系统ElK基础filebeat收集日志(4)
    linux系统ElK基础(3)
    linux系统ElK基础(2)
  • 原文地址:https://www.cnblogs.com/lsz3034/p/4537676.html
Copyright © 2011-2022 走看看