日期:2014-05-17 浏览次数:20805 次
public static void main(String[] args) throws JdException {
JingDongTest jdt = new JingDongTest();
jdt.run();
}
public void run() throws JdException {
String serverUrl="http://gw.api.360buy.com/routerjson";//这个应该是调用接口的,这里应该怎么填?我想调用的接口是add(添加),名称: 360buy.ware.add
String appKey="34D";//认证用户值
String appSecret="472";//认证密码
String accessToken="04b";//认证令牌
client =new DefaultJdClient(serverUrl, accessToken, appKey, appSecret);
WareAddRequest wareAddRequest = new WareAddRequest();
wareAddRequest.setCid("1354"); // 类目 服饰鞋帽 > 女装 > 衬衫 (1354) 药品 >感冒用药 > 风寒风热(6359)
try {
wareAddRequest.setWareImage(WriteImg());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // 主图
wareAddRequest.setTitle("API商品测试-商品名称1111");
wareAddRequest.setLength("1");
wareAddRequest.setWide("2");
wareAddRequest.setHigh("3");
wareAddRequest.setWeight("11");
wareAddRequest.setMarketPrice("500"); // 市场价
wareAddRequest.setJdPrice("444"); // 京东价
wareAddRequest.setNotes("描述123123");// 描述
wareAddRequest.setPackListing("包装清单"); // 包装清单
wareAddRequest.setService("售后服务"); // 售后服务
wareAddRequest.setStockNum("100");
wareAddRequest.setAttributes("3205:64734|3206:22107");
wareAddRequest.setSkuProperties("1000000041:150029941^1000000046:150029944|1000000041:150029941^1000000046:150029943");
wareAddRequest.setSkuPrices("300|500");
wareAddRequest.setSkuStocks("10|90");
System.out.println("1:"+new Date().getTime());
WareAddResponse wareAddResponse= client.execute(wareAddRequest);
System.out.println("2:"+new Date().getTime());
}
public byte[] WriteImg() throws Exception{
File f=new File( "d:/图片.jpg ");
FileInputStream fis=new FileInputStream (f);
int len=(int)f.length();
byte by[]=new byte[len];
fis.read(by);
fis.close();
return by;
}