예제 #1
0
        private string get_jsapi_ticket(string access_token)
        {
            var ticket = WXInterface.GetTicket(access_token, "jsapi");

            if (ticket != null)
            {
                return(ticket.ticket);
            }
            return("");

            /*
             * if (null == apiticket) {
             * String url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
             * String jsonStrTicket = Tools.sendGet(url, "access_token=" + access_token + "&type=jsapi");
             *
             * logger.debug("[jsonStrTicket] = " + jsonStrTicket);
             *
             * JSONObject json = JSONObject.fromObject(jsonStrTicket);
             * ticket = (String) json.get("ticket");
             *
             * } else {
             * ticket = (String) apiticket;
             * }
             * */
        }
예제 #2
0
        public void GetWXConfig()
        {
            var dtNow = DateTime.Now;
            //string nonceStr = "Wm3WZYTPz0wzccnW";// DateTime.Now.ToString("yyyyMMddHHmmss");
            string nonceStr  = WxJSSDKConfig.create_nonce_str(16);
            long   timestamp = WxJSSDKConfig.create_timestamp(dtNow);
            var    token     = WXInterface.GetAccessToken(Config.AppID, Config.AppSecret).access_token;

            if (token != null)
            {
                string url    = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;//获取当前url
                var    ticket = WXInterface.GetTicket(token, "jsapi");
                if (ticket != null)
                {
                    string signature = create_signature(ticket.ticket, nonceStr, timestamp.ToString(), url);
                    ViewBag.ticket    = ticket.ticket;
                    ViewBag.signature = signature;
                }
                ViewBag.token     = token;
                ViewBag.nonceStr  = nonceStr;
                ViewBag.timestamp = timestamp;
                ViewBag.appId     = Config.AppID;
                ViewBag.url       = url;
            }
        }