改post
parent
a906ad4712
commit
283439f860
|
|
@ -284,7 +284,13 @@ public class BuyGoodsNewLogic {
|
||||||
jsonObject2.put("_mac", reportBaseBean != null ? reportBaseBean.getNetwork_s() : "");
|
jsonObject2.put("_mac", reportBaseBean != null ? reportBaseBean.getNetwork_s() : "");
|
||||||
|
|
||||||
jsonObject.put("context", jsonObject2);
|
jsonObject.put("context", jsonObject2);
|
||||||
String result = HttpPool.doPost(DataMessageUtils.restURL, jsonObject);
|
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("appid","e7ba14d6442b0ec225289bc846826092");
|
||||||
|
params.put("who", user.getPlayerInfoManager().getOpenId());
|
||||||
|
params.put("context", jsonObject2.toJSONString());
|
||||||
|
String result = HttpPool.doPost(DataMessageUtils.restURL, params);
|
||||||
|
// String result = HttpPool.doPost(DataMessageUtils.restURL, jsonObject);
|
||||||
LOGGER.info("onChargeSuccess uid={} REST付费上报={} 参数={}", user.getId(), result, jsonObject.toJSONString());
|
LOGGER.info("onChargeSuccess uid={} REST付费上报={} 参数={}", user.getId(), result, jsonObject.toJSONString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,33 @@ public class HttpPool {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static String doPost(String url, Map<String,String> parms) throws IOException {
|
||||||
|
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||||
|
HttpPost httpPost = new HttpPost(url);
|
||||||
|
List<NameValuePair> nvps =getFromMap(parms);
|
||||||
|
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
|
||||||
|
CloseableHttpResponse response2 = httpclient.execute(httpPost);
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpEntity entity = response2.getEntity();
|
||||||
|
return EntityUtils.toString(entity);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
response2.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<NameValuePair> getFromMap(Map<String,String> parms){
|
||||||
|
List<NameValuePair> nvps = new ArrayList<NameValuePair>(parms.size());
|
||||||
|
for(Map.Entry<String,String> item : parms.entrySet()){
|
||||||
|
nvps.add(new BasicNameValuePair(item.getKey(), item.getValue()));
|
||||||
|
}
|
||||||
|
return nvps;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组装Post请求路径
|
* 组装Post请求路径
|
||||||
* @param url
|
* @param url
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue