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" => "2015-07-06 00:00:01",
)
)
);
$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("", "", "", "");
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 = "http://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();
}
}
} |