コード例 #1
0
        public void GetTicket_AppCode_NotNull()
        {
            IWeChatAppService appService = container.Resolve <IWeChatAppService>();
            var app    = appService.GetApp(Constants.MOBILE_APPROVAL);
            var ticket = JsApiTicketManager.TryGetTicket("wx2e8cc6975a5fa1ce", app.SecretValue);

            Assert.IsNotNull(ticket);
            Console.WriteLine(ticket);
        }
コード例 #2
0
ファイル: JSSDKHandler.cs プロジェクト: 476344704/WeChat.Dev
        /// <summary>
        /// 获取jsapi权限签名
        /// </summary>
        /// <param name="currentURL">当前URL地址</param>
        /// <returns></returns>
        public JsApiTicketResult GetSignature(string url)
        {
            var jsapi_ticket = JsApiTicketManager.TryGetTicket(AppConfig.CorpId, AppConfig.Secret);
            var timestamp    = JSSDKHelper.GetTimestamp();
            var noncestr     = JSSDKHelper.GetNoncestr();
            var signature    = JSSDKHelper.GetSignature(jsapi_ticket, noncestr, timestamp, url);

            return(new JsApiTicketResult
            {
                AppId = AppConfig.CorpId, // 必填,企业号的唯一标识,此处填写企业号corpid
                Timestamp = timestamp,    // 必填,生成签名的时间戳
                Noncestr = noncestr,      // 必填,生成签名的随机串
                Signature = signature,    // 必填,签名,见附录1
                JsapiTicket = jsapi_ticket
            });
        }