资源简介
微信基于Oauth2获取用户基本信息,保证可用。
代码片段和文件信息
public class HttpUtil {
public static String getUrl(String get_access_token_url) {
String result = null;
try {
HttpGet request = new HttpGet(get_access_token_url);
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpResponse response = httpclient.execute(request);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
result= EntityUtils.toString(response.getEntity()“utf-8“);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
}
评论
共有 条评论