Beispiel #1
0
        /// <summary>
        /// 获取jssdk签名配置对象
        /// </summary>
        /// <param name="url">当前页面url</param>
        /// <param name="jsapi">JsApiEnum,如:JsApiEnum.scanQRCode|JsApiEnum.onMenuShareQQ</param>
        /// <returns>微信公众平台JsSdk的配置对象</returns>
        public SignPackage GetSignPackage(string url, JsApiEnum jsapi)
        {
            /*
             * 签名字段
             * noncestr=Wm3WZYTPz0wzccnW
             * jsapi_ticket=sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg
             * timestamp=1414587457
             * url=http://mp.weixin.qq.com?params=value
             */
            string noncestr     = this.CreateNonceStr(16);
            string jsapi_tkcket = this.GetJsApiTicket();
            long   timestamp    = TimeStamp.Now();
            Dictionary <string, string> signData = new Dictionary <string, string>()
            {
                { "noncestr", noncestr },
                { "jsapi_ticket", jsapi_tkcket },
                { "timestamp", timestamp.ToString() },
                { "url", url }
            };

            SignPackage result = new SignPackage()
            {
                appId     = this.appId,
                timestamp = timestamp,
                nonceStr  = noncestr,
                debug     = this._debug,
                signature = new Signature().Sign(signData),
                jsApiList = jsapi.ToString().Replace(" ", "").Split(',')
            };

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// ��ȡjssdkǩ�����ö���
        /// </summary>
        /// <param name="url">��ǰҳ��url</param>
        /// <param name="jsapi">JsApiEnum,��:JsApiEnum.scanQRCode|JsApiEnum.onMenuShareQQ</param>
        /// <returns>΢�Ź���ƽ̨JsSdk�����ö���</returns>
        public SignPackage GetSignPackage(string url, JsApiEnum jsapi)
        {
            /*
             * ǩ���ֶ�
            noncestr=Wm3WZYTPz0wzccnW
            jsapi_ticket=sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg
            timestamp=1414587457
            url=http://mp.weixin.qq.com?params=value
             */
            string noncestr = this.CreateNonceStr(16);
            string jsapi_tkcket = this.GetJsApiTicket();
            long timestamp = TimeStamp.Now();
            Dictionary<string, string> signData = new Dictionary<string, string>() {
                {"noncestr",noncestr},
                {"jsapi_ticket",jsapi_tkcket},
                {"timestamp",timestamp.ToString()},
                {"url",url}
            };

            SignPackage result = new SignPackage()
            {
                appId = this.appId,
                timestamp = timestamp,
                nonceStr = noncestr,
                debug = this._debug,
                signature = new Signature().Sign(signData),
                jsApiList = jsapi.ToString().Replace(" ", "").Split(',')
            };
            return result;
        }