Exemple #1
0
        /// <summary>
        /// 根据微信 Code 获取微信 OpenID
        /// </summary>
        /// <returns></returns>
        public string GetOpenId(string appId, string appSecret, string code)
        {
//#if !DEBUG
            //获取缓存
            string openId = CookiesKit.GetCookie("OpenId");

            if (!string.IsNullOrEmpty(openId))
            {
                return(openId);
            }

            if (!string.IsNullOrEmpty(code))
            {
                OWebAccessTokenAPI atapi = new OWebAccessTokenAPI(appId, appSecret, code);
                OWebAccessToken    at    = atapi.GetWebAccessToken();
                CookiesKit.SetCookie("OpenId", at.OpenId);

                return(at.OpenId);
            }
            return(string.Empty);
//#else
//            return "ornCZt1qWRaya7C3Xd1-pN1ktFrI";
//#endif
        }
Exemple #2
0
        /// <summary>
        /// 获取 Web 访问令牌
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="appSecret"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public OWebAccessToken GetWebAccessToken(string appId, string appSecret, string code)
        {
            OWebAccessTokenAPI api = new OWebAccessTokenAPI(appId, appSecret, code);

            return(api.GetWebAccessToken());
        }