httpclient使用,待完善
来源:互联网 发布:linux cp cannot stat 编辑:程序博客网 时间:2024/04/30 16:53
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 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);
0 0
- httpclient使用,待完善
- curl使用(待完善)
- Android_Vitamio使用(待完善)
- FFMpeg使用实例--待完善
- 待完善。。
- 待完善
- 待完善
- 待完善
- 待完善
- 待完善
- 待完善
- dev 控件使用技巧,待完善
- Calendar类的使用,待完善
- Android动画使用总结(待完善)
- sort、uniq、comm命令使用---待完善
- linux svn使用实例(待完善)
- 关于sun.misc.Unsafe类的使用(待完善)
- 使用SqlMapClient后sql的写法(待完善)
- 动态计算UITableViewCell高度详解
- 22.Generate Parentheses&n对括号的全部有效组合
- 曾经是福布斯杂志富豪排行榜上赫赫有名
- 扩展SpringMVC以支持更精准的数据绑定
- java三种排序比较
- httpclient使用,待完善
- Linux系统下使用mail发送一封简单的Internet邮件【以及验证邮件是否发送成功sendmail -bp,必须是root用户才可以使用此命令查看邮件消息队列中的内容】
- JSTL标签 参考手册
- 动态内表
- 扩展SpringMVC以支持绑定JSON格式的请求参数
- LightOJ - 1317 Throwing Balls into the Baskets 期望
- SAT阅读应对方法及相关要求
- spark集群搭建
- textView键盘被遮挡问题