예제 #1
0
        /// <summary>
        /// 获取成员信息
        /// </summary>
        /// <param name="corpId">企业ID</param>
        /// <param name="corpSecret">企业应用秘钥</param>
        /// <param name="code">通过员工授权获取到的code,每次员工授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期</param>
        /// 权限说明:管理员须拥有agent的使用权限;agentid必须和跳转链接时所在的企业应用ID相同</param>
        /// <returns></returns>
        public static GetUserInfoResult GetUserId(string corpId, string corpSecret, string code)
        {
            var accessToken = AccessTokenManager.TryGetToken(corpId, corpSecret, true);
            var url         = string.Format("https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={0}&code={1}", accessToken.AsUrlData(), code.AsUrlData());

            return(Get.GetJson <GetUserInfoResult>(url));
        }
예제 #2
0
        public virtual AppResult TryGetToken(string appcode)
        {
            var app         = _appService.GetApp(appcode);
            var accessToken = AccessTokenManager.TryGetToken(CorpID, app.SecretValue);

            return(new AppResult
            {
                AccessToken = accessToken,
                AgentId = app.WeChatAppID
            });
        }