// String code = request.getParameter(“code”);
String code = body;
System.out.println("++++++++++++++++++++++++++++++code:" + code);
Map map = new HashMap();
if (code != null) {
//获取openid和access_token的连接
// String getOpenIdUrl = “https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=secret&code=CODE&grant_type=authorization_code”
//获取返回的code
String requestUrl = getOpenIdUrl.replace(“CODE”, code);
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(requestUrl);
ResponseHandler responseHandler = new BasicResponseHandler();
//向微信发送请求并获取response
String response = httpClient.execute(httpGet, responseHandler);
JsonParser parser = new JsonParser();
Js
微信h5授权获取用户信息
最新推荐文章于 2024-07-13 15:20:17 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)