public static String sendPostMethod(String path,Map<String, Object>params,String encoding){
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(path);
String result = "";
List<BasicNameValuePair> parameters = new ArrayList<BasicNameValuePair>();
try {
if(params!=null && !params.isEmpty()){
for(Map.Entry<String, Object> entry:params.entrySet()){
String name = entry.getKey();
String value = entry.getValue().toString();
BasicNameValuePair valuePair = new BasicNameValuePair(name, value);
parameters.add(valuePair);
}
}
UrlEncodedFormEntity encodedFormEntity = new UrlEncodedFormEntity(parameters);
httpPost.setEntity(encodedFormEntity);
HttpResponse httpResponse = httpClient.execute(httpPost);
if(httpResponse.getStatusLine().getStatusCode()==200){
result = EntityUtils.toString(httpResponse.getEntity());
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return result;
}
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(path);
String result = "";
List<BasicNameValuePair> parameters = new ArrayList<BasicNameValuePair>();
try {
if(params!=null && !params.isEmpty()){
for(Map.Entry<String, Object> entry:params.entrySet()){
String name = entry.getKey();
String value = entry.getValue().toString();
BasicNameValuePair valuePair = new BasicNameValuePair(name, value);
parameters.add(valuePair);
}
}
UrlEncodedFormEntity encodedFormEntity = new UrlEncodedFormEntity(parameters);
httpPost.setEntity(encodedFormEntity);
HttpResponse httpResponse = httpClient.execute(httpPost);
if(httpResponse.getStatusLine().getStatusCode()==200){
result = EntityUtils.toString(httpResponse.getEntity());
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return result;
}