PHP | <?php
require_once '../WdtClient.php';
$c = new WdtClient();
$c->sid = '';
$c->appkey = '';
$c->appsecret = '';
$c->gatewayUrl = 'http://sandbox.wangdian.cn/openapi2/goods_push.php';
$goods_list[] = array
(
"goods_no" => "test001",
"goods_type" => 1,
"goods_name" => "test",
"spec_list" => array ( array(
"spec_no" => "ghs_123",
"spec_code" => "test001_01",
"barcode" => "test001",
"spec_name" => "test",
"lowest_price" => 1,
"img_url" => 'http://baidu.com',
"retail_price" => 1,
"wholesale_price" => 1,
"member_price" => 1,
"market_price" => 1,
"sale_score" => 1,
"pack_score" => 1,
"pick_score" => 1,
"validity_days" => 30,
)
)
);
$c->putApiParam('goods_list', json_encode($goods_list), JSON_UNESCAPED_UNICODE);
$json = $c->wdtOpenApi();
var_dump($json);
?> |
JAVA | package com.wangdian.api.goods;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.wangdian.api.WdtClient;
public class GoodsPush {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
// TODO Auto-generated method stub
WdtClient client = new WdtClient("传入sid", "传入appkey", "传入appsecret", "传入url");
//测试环境sid、appkey、密钥请到旺店通开放平台-自助对接-申请测试环境内查看,测试环境url=https://sandbox.wangdian.cn/openapi2/
//调用正式环境时请将sid、appkey、appsecret切换为实际参数,参数在旺店通开放平台-自助对接-应用管理内应用状态为已上线的应用中查看,调用正式环境注意切换正式环境url=https://api.wangdian.cn/openapi2/
Map<String, Object>[] goods_list = new Map[1];
Map<String, Object>[] spec_list = new Map[2];
spec_list[0] = new HashMap<String, Object>();
spec_list[0].put("spec_no", "ghs2018120503");
spec_list[0].put("spec_code", "test001_01132");
spec_list[0].put("spec_name", "test001_01132");
spec_list[1] = new HashMap<String, Object>();
spec_list[1].put("spec_no", "ghs2018120505");
spec_list[1].put("spec_code", "test001_01134");
spec_list[1].put("spec_name", "test001_01133");
goods_list[0] = new HashMap<String,Object>();
goods_list[0].put("goods_no", "ghs1207");
goods_list[0].put("goods_type","1");
goods_list[0].put("goods_name", "stest");
goods_list[0].put("spec_list", spec_list);
//通过第三方json解析工具类fastjson将map解析成json
String goods_list_json = JSON.toJSONString(goods_list);
//System.out.println(goods_list_json);
Map<String, String> params = new HashMap<String, String>();
params.put("goods_list", goods_list_json);
try {
String response = client.execute("goods_push.php", params);
System.out.println(response);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
C# | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WdtSdk;
namespace GoodsPush
{
class GoodsPush
{
static void Main(string[] args)
{
WdtClient client = new WdtClient();
client.sid = "";
client.appkey = "";
client.appsecret = "";
client.gatewayUrl = "https://sandbox.wangdian.cn/openapi2/goods_push.php";
var goods_list = new[]
{
new
{
goods_no="llxxtest",
goods_type=1,
goods_name="测试测试ceshi",
spec_list=new[]
{
new
{
spec_no="myxx",
spec_code = "myxx",
spec_name = "满夜雪啸"
},
new
{
spec_no="dshg",
spec_code = "dshg",
spec_name = "凋松鹤骨"
},
new
{
spec_no="mhgs",
spec_code = "mhgs",
spec_name = "梦回姑苏"
}
}
}
};
string json = goods_list.ToJsonString();
client.putParams("goods_list", json);
string result = client.wdtOpenapi();
Console.WriteLine(result);
Console.ReadKey();
}
}
} |
python | import WdtClient
import json
t = WdtClient.WdtClient('appkey', 'appsecret', 'sid', 'http://sandbox.wangdian.cn/openapi2/')
goods_list = []
spec_list = []
spec_1 = {}
spec_1.update({"spec_no": 'spec_001'})
spec_1.update({"spec_code": '12345'})
spec_1.update({"barcode": '12345678'})
spec_1.update({"spec_name": '规格名称'})
spec_1.update({"spec_unit_name": '基本单位'})
spec_1.update({"lowest_price": '最低价'})
spec_1.update({"retail_price": '零售价'})
spec_1.update({"wholesale_price": '批发价'})
spec_1.update({"member_price": '会员价'})
spec_1.update({"market_price": '市场价'})
spec_1.update({"spec_remark": '备注'})
spec_list.append(spec_1)
goods_1 = {}
goods_1.update({"goods_no": 'goods_001'})
goods_1.update({"goods_type": 1})
goods_1.update({"goods_name": '货品名称'})
goods_1.update({"short_name": '货品简称'})
goods_1.update({"alias": '货品别名'})
goods_1.update({"origin": '产地'})
goods_1.update({"class_name": '分类'})
goods_1.update({"brand_name": '品牌'})
goods_1.update({"unit_name": '基本单位'})
goods_1.update({"remark": '备注'})
goods_1.update({"props1": '自定义属性1'})
goods_1.update({"props2": '自定义属性2'})
goods_1.update({"props3": '自定义属性3'})
goods_1.update({"props4": '自定义属性4'})
goods_1.update({"props5": '自定义属性5'})
goods_1.update({"props6": '自定义属性6'})
goods_1.update({"aux_unit_name": '辅助单位名称'})
goods_1.update({"flag_name": '标记名称'})
goods_1.update({"spec_list": spec_list})
goods_list.append(goods_1)
# del(goods_list[0])
jsonArr = json.dumps(goods_list, ensure_ascii=False)
params = {}
params.update({"goods_list": jsonArr})
response = t.execute("goods_push.php", params)
print(response) |