我根据有赞API的新增一个商品的接口提供的java例子进行上传是写了如下代码,运行不能正常上传我调用的api是kdt.item.add 新增一个商品 - public String createXCTravelProduct(String m_product_value){
-
- String result2 = "";
- String title = "商品标题,商品标题。不能超过100字,受违禁词控制,必填";//必填
- String Desc = "商品描述,商品描述。字数要大于5个字符,小于25000个字符 ,受违禁词控制,非必填";//非必填
- float Price = 12.22f;//商品价格。取值范围 0.01-100000000 精确到2位小数 单位元。需要在Sku价格所决定的的区间内,必填
- float PostFee = 0f;//运费。取值范围 0.00-999.00 精确到2位小数 单位元 ;必填
- Auth sign = new Sign(app_id, AppSecret);
- KDTClient client = new DefaultKDTClient(sign); //new Sign(appKey, appSecret)
- KdtItemAddParams kdtItemAddParams = new KdtItemAddParams();
- kdtItemAddParams.setTitle(title);
- kdtItemAddParams.setDesc(Desc);
- kdtItemAddParams.setPrice(Price);
- kdtItemAddParams.setPostFee(PostFee);
- ByteWrapper[] byteWrappers = new ByteWrapper[1];
- // 文件被包装成ByteWrapper
- ByteWrapper byteWrapper = new ByteWrapper("D:\\picture\\BO_L.jpg");
- byteWrappers[0] = byteWrapper;
- kdtItemAddParams.setImages(byteWrappers);
- KdtItemAdd kdtItemAdd = new KdtItemAdd();
- kdtItemAdd.setAPIParams(kdtItemAddParams);
- KdtItemAddResult result = client.invoke(kdtItemAdd);
- System.out.println(result.getItem().getTitle());
- return result2;
- }
复制代码
运行后异常提醒如下- Exception in thread "main" java.lang.RuntimeException: javax.net.ssl.SSLException: hostname in certificate didn't match: <open.youzan.com> != <*.koudaitong.com> OR <koudaitong.com> OR <*.koudaitong.com>
- at com.youzan.open.sdk.util.http.DefaultHttpClient.post(DefaultHttpClient.java:92)
- at com.youzan.open.sdk.client.executor.AbstractExecutor.doExecuteInternal(AbstractExecutor.java:80)
- at com.youzan.open.sdk.client.executor.AbstractExecutor.execute(AbstractExecutor.java:28)
- at com.youzan.open.sdk.client.core.DefaultKDTClient.execute(DefaultKDTClient.java:77)
- at com.youzan.open.sdk.client.core.DefaultKDTClient.invoke(DefaultKDTClient.java:84)
复制代码 我调用的是从有赞上下载的SDK,应该不涉及让我编辑什么;我要正常上传产品需要做些什么处理
我引入的类如下- import com.youzan.open.sdk.client.auth.Auth;
- import com.youzan.open.sdk.client.auth.Sign;
- import com.youzan.open.sdk.client.core.DefaultKDTClient;
- import com.youzan.open.sdk.client.core.KDTClient;
- import com.youzan.open.sdk.gen.v1_0_0.api.KdtItemAdd;
- import com.youzan.open.sdk.gen.v1_0_0.model.KdtItemAddParams;
- import com.youzan.open.sdk.gen.v1_0_0.model.KdtItemAddResult;
- import com.youzan.open.sdk.model.ByteWrapper;
复制代码
本帖最后由 汇程旅行 于 2017-2-22 15:02 编辑
|
|
用手机打开
收藏
赞 0
···
回复
|
|
|
|