/// <summary> /// 获取微信token /// https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET /// </summary> private void GetAccessToken() { //accessToken = "25_pF9QK4Cacf09M6v5G8mxQu1bKkwg0Fnd2Q1B-J6kgAWVVQPXVTXuuRPEAmQ16Q3hu8yD1ETKKEo0UhN87c2kc2rFoQ3FDENevZ9ZrW8N6gIIBsd1s4DlOuYfeanm7-gFR9v9vPq7SQjWM8oUUEReAIAJTG"; //expires = DateTime.Now; //AccessToken 过期 if (Expires.AddSeconds(expires_in) < DateTime.Now || string.IsNullOrEmpty(AccessToken)) { var url = "https://" + $"api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={MinAppID}&secret={MinAppSecret}"; Console.WriteLine("url:" + url); string data = HttpService.Get(url); var result = JsonConvert.DeserializeObject <WxPackage.Token>(data); if (!string.IsNullOrEmpty(result?.access_token)) { AccessToken = result.access_token; Expires = DateTime.Now; } Console.WriteLine("Token:" + AccessToken); } }