public static void main(String[] args) throws ClientProtocolException, IOException, InvalidKeyException, NoSuchAlgorithmException {
HttpClient httpclient = new DefaultHttpClient();
List<NameValuePair> list = new ArrayList<NameValuePair>();
list.add(new BasicNameValuePair("bill_id","06757487"));
list.add(new BasicNameValuePair("status","paid"));
list.add(new BasicNameValuePair("error","0"));
list.add(new BasicNameValuePair("user","123"));
Map<String,String> map = new HashMap<String, String>();
map.put("bill_id","06757487");
map.put("status","paid");
map.put("error","0");
map.put("user","123");
String src = generateSignString(map);
String sign = DigestUtil.getHAMC_SHA1Signature(src, "SNVDTLDHTBDNLYV");
HttpPost post = new HttpPost("http://localhost:8082/lcpay_notify/qiwiNotify");
post.setHeader("Accept", "application/xml");
post.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
post.setHeader("X-Api-Signature",sign);
UrlEncodedFormEntity formEntity = null;
formEntity = new UrlEncodedFormEntity(list, "utf-8");
post.setEntity(formEntity);
// 发起交易
HttpResponse resp = httpclient.execute(post);
HttpEntity entity = resp.getEntity();
BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8"));
StringBuffer responseString = new StringBuffer();
String result = br.readLine();
while (result != null) {
responseString.append(result);
result = br.readLine();
}
System.out.println(responseString);
httpclient使用,待完善
原创
©著作权归作者所有:来自51CTO博客作者tianwc的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
【无标题】待完善
pcie
fpga开发 Express System -
zabbix-api,待完善
zabbix-api
zabbix-api -
python机器学习(待完善)
分类: 朴素贝叶斯 , 最近邻居法k-NN
机器学习 python 朴素贝叶斯 -
查找方法总结---待完善
之前保存在其他网站的博客
算法 数据结构 -
JVM(待完善)
回收机制 JVM调优 ...
jvm调优 模式 -
ApplicationEventPublisherAware--待完善
ApplicationEventPublisherAware
spring aware 源码 其他