zhaojs
2023-09-27 74098f1401afe40f961d1d167bb18dd0a71c4d59
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Collections.Generic;
using System.Text;
using CommonUtil.Web;
using CommonUtil;
using WeiXinKfSDK.Response;
using RestSharp;
using WeiXinKfSDK.Request;
using Newtonsoft.Json;
using System.Reflection;
 
namespace WeiXinKfSDK
{
    public class QwClient
    {
        /// <summary>
        /// 获取企微access_token
        /// </summary>
        public static QwGetAccessTokenResponse GetAccessToken()
        {
            string getUrl = $"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={WeiXinKfSetting._qwCorpid}&corpsecret={WeiXinKfSetting._qwSecret}";
            string resStr = new WebUtil().DoGet(getUrl, null);
            LogUtil.Info($"[获取access_token]返回:{resStr}", "企微接口请求日志");
            if (resStr.IsNullOrEmpty())
            {
                return null;
            }
            QwGetAccessTokenResponse response = JSONUtil.JsonToObject<QwGetAccessTokenResponse>(resStr);
            return response;
        }
    }
}