码迷,mamicode.com
首页 > 微信 > 详细

java 微信授权后获取微信用户信息昵称乱码问题 解决

时间:2016-07-14 19:10:29      阅读:1010      评论:0      收藏:0      [点我收藏+]

标签:

String getUserInfoUrl = "https://api.weixin.qq.com/sns/userinfo?access_token="+access_token+"&openid="+openid+"&lang=zh_CN";
URL url1 = new URL(getUserInfoUrl);
HttpURLConnection urlConnection = (HttpURLConnection)url1.openConnection();


// 将返回的输入流转换成字符串
InputStream inputStream = urlConnection.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream,"UTF-8");
BufferedReader in = new BufferedReader(inputStreamReader);
String jsonUserStr =in.readLine().toString();
out.println("jsonUserStr = "+jsonUserStr);


// 释放资源
inputStream.close();
inputStream = null;
urlConnection.disconnect();


JSONObject jsonUserObject = new JSONObject(jsonUserStr);

java 微信授权后获取微信用户信息昵称乱码问题 解决

标签:

原文地址:http://www.cnblogs.com/libra0920/p/5671193.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!