80,475
社区成员
发帖
与我相关
我的任务
分享
HttpClient httpClient=new DefaultHttpClient();
HttpGet httpGet=new HttpGet(
"http://route.showapi.com/9-7"+"?"+"area=北京&areaid=&month=201606&showapi_appid=22661&showapi_sign=fa597c55d97d435ebbc67bc9dd45fe83");
HttpResponse response = httpClient.execute(httpGet);
int code = response.getStatusLine().getStatusCode();
if(code== HttpStatus.SC_OK){
HttpEntity entity = response.getEntity()
String s1 = EntityUtils.toString(entity, "utf-8");
System.out.println(s1);
}
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost=new HttpPost("http://route.showapi.com/9-7");
List<BasicNameValuePair> list=new ArrayList<BasicNameValuePair>();
list.add(new BasicNameValuePair("showapi_sign","fa597c55d97d435ebbc67bc9dd45fe83"));
list.add(new BasicNameValuePair("showapi_appid","22661"));
list.add(new BasicNameValuePair("area","北京"));
list.add(new BasicNameValuePair("month","201607"));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list);
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost);
if(response.getStatusLine().getStatusCode()== HttpStatus.SC_OK){
HttpEntity entity1 = response.getEntity();
String s1 = EntityUtils.toString(entity1, "utf-8");
System.out.println(s1);
}

