/**
* post
* @return 返回连接接口是否成功
*/
public static boolean applayPost(PublishProduct product){
try {
HttpClient client =new HttpClient();
PostMethod method=new PostMethod("http://adad.ada.adada");
//中文编码
method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "gb2312");
NameValuePair[] parts = {
new NameValuePair("data", product.toEncodeJson()),
new NameValuePair("pwd", "123"),
};
try {
method.setRequestBody(parts);
client.executeMethod(method);
String rspStr=method.getResponseBodyAsString();
LOGGER.info("服务器返回"+rspStr);
} catch (IOException e) {
LOGGER.error(getExceptionTrace(e));
e.printStackTrace();
}
} catch (Exception e) {
LOGGER.error(getExceptionTrace(e));
e.printStackTrace();
}
return false;
}
/**
* get
* @return 返回连接接口是否成功
*/
public static boolean applayGet(String song_id){
try {
HttpClient client =new HttpClient();
GetMethod method=new GetMethod("http://sdfsdfsdfsdfsf?songid="+song_id);
//中文编码
method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "gb2312");
try {
client.executeMethod(method);
String rspStr=method.getResponseBodyAsString();
LOGGER.info("服务器返回"+rspStr+":);
} catch (IOException e) {
LOGGER.error(getExceptionTrace(e));
e.printStackTrace();
}
} catch (Exception e) {
LOGGER.error(getExceptionTrace(e));
e.printStackTrace();
}
return false;
}