接口规范(产品订购)
Posted AugustTwenty
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了接口规范(产品订购)相关的知识,希望对你有一定的参考价值。
package com.fenxiao.channel.quxun; import java.io.IOException; import java.util.Map; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import com.fenxiao.channel.qiannai.util.MD5Util; /** * 2.1.产品订购 * @author wn * */ public class JiuDianjiuTest { @SuppressWarnings("unused") private Logger log = LogManager.getLogger(JiuDianjiuTest.class); @SuppressWarnings({ "rawtypes"}) public Object testOrder() throws HttpException,IOException{ String accountVal = "13301516477"; //手机号码 String notifyUrl = "https://www.baidu.com/"; //通知回调地址 String orderNo = "23167771251045981811249827799033"; //渠道订单编码 String supplierId = "kedang201605042323erwg"; //渠道代码 String spuId = "LT010020" ; //产品代码 String ts = System.currentTimeMillis()+""; //时间戳 String sign = ""; //签名 String key ="kedang0504"; //密钥 //拼接成字符串 StringBuffer sb = new StringBuffer(); sb.append("accountVal").append(accountVal).append("notifyUrl").append( notifyUrl).append("orderNo") .append(orderNo).append("spuId").append(spuId).append("supplierId").append(supplierId).append("ts").append(ts).append(key); System.out.println("33333"+sb.toString()); sign = MD5Util.encrypt(sb.toString()); String url = "http://cz.9dian9.cn/u/stdchn/kedang/charge.xml"; //请求地址 HttpClient client = new HttpClient(); client.getParams().setContentCharset("UTF-8"); PostMethod postMethod = new PostMethod(url); String s = "supplierId="+supplierId+"&sign="+sign+"&spuId="+spuId+"&orderNo="+orderNo+"&accountVal="+accountVal+"¬ifyUrl="+notifyUrl+"&ts="+ts; System.out.println(s); postMethod.addParameter("supplierId", supplierId); // 商户号 postMethod.addParameter("sign", sign); // 签名 postMethod.addParameter("spuId", spuId); // 产品号 postMethod.addParameter("orderNo", orderNo); // 流水号 postMethod.addParameter("accountVal", accountVal); // 手机号 postMethod.addParameter("notifyUrl", notifyUrl); // 回调地址 postMethod.addParameter("ts", ts); // 日期 Map resultMap = null; client.executeMethod(postMethod); System.out.println(postMethod.getResponseBodyAsString()); return resultMap; } public static void main(String[] args) throws HttpException, IOException { JiuDianjiuTest test = new JiuDianjiuTest(); test.testOrder(); } }
以上是关于接口规范(产品订购)的主要内容,如果未能解决你的问题,请参考以下文章