-
@param secretKey 小程序密钥
-
@return access_token
-
@throws Exception
*/
public static String postToken() throws Exception {
String apiKey = “”;//小程序id
String secretKey = “”;//小程序密钥
String requestUrl = "https:
《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》
【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享
//api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+apiKey+"&secret="+secretKey;
URL url = new URL(requestUrl);
// 打开和URL之间的连接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 设置通用的请求属性
connection.setRequestProperty(“Content-Type”, “application/json”);
connection.setRequestProperty(“Connection”, “Keep-Alive”);
connection