params = new ArrayList();
for (String key:body.keySet()){
params.add(new BasicNameValuePair(key, body.get(key).toString()));
}
HttpEntity reqEntity = new UrlEncodedFormEntity(params);
System.out.println("the request body is:"+EntityUtils.toString(reqEntity));
httpPost.setEntity(reqEntity);
httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");
}
}
HttpResponse result = httpClient.execute(httpPost);
System.out.println(result.getStatusLine().getStatusCode());
if (302 == result.getStatusLine().getStatusCode()) {
System.out.println(result.getFirstHeader("location"));
return result.getFirstHeader("location").getValue();
}
HttpEntity entity = result.getEntity();
return EntityUtils.toString(entity, "UTF-8");
}catch(Exception e){
e.printStackTrace();
}
return null;
}