PHP | <?php
require_once '../WdtClient.php';
$c = new WdtClient();
$c->sid = '';
$c->appkey = '';
$c->appsecret = '';
$c->gatewayUrl = 'http://sandbox.wangdian.cn/openapi2/api_goodsspec_push.php';
$api_goods_info = array(
'platform_id'=>127,
'shop_no' => 'shop_test',
'goods_list'=>array(
array (
"status" => "1",
"goods_id" => "20151009100903",
"goods_no" => "xjftest002",
"cid" => "1",
"goods_name" => "test",
"price" => "1",
"stock_num" => "2",
"pic_url" => "",
"spec_id" => "20151009100903",
"spec_code" => "test002",
"spec_name" => "test",
"spec_no" => "xjftest004"
)
)
);
$c->putApiParam('api_goods_info', json_encode($api_goods_info, 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 ApiGoodsSpecPush {
@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> api_goods_info = new HashMap<String,Object>();
Map<String, Object>[] goods_list = new Map[1];
goods_list[0] = new HashMap<String,Object>();
goods_list[0].put("goods_id", "20151009100903");
goods_list[0].put("spec_id","20151009100903");
goods_list[0].put("goods_no", "stest");
goods_list[0].put("spec_no", "stes12");
goods_list[0].put("status", "1");
api_goods_info.put("platform_id", "127");
api_goods_info.put("shop_no", "lx2test");
api_goods_info.put("goods_list", goods_list);
//通过第三方json解析工具类fastjson将map解析成json
String api_goods_info_json = JSON.toJSONString(api_goods_info);
//System.out.println(goods_list_json);
Map<String, String> params = new HashMap<String, String>();
params.put("api_goods_info", api_goods_info_json);
try {
String response = client.execute("api_goodsspec_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 ApiGoodsspecPush
{
class ApiGoodsspecPush
{
static void Main(string[] args)
{
WdtClient client = new WdtClient();
client.sid = "";
client.appkey = "";
client.appsecret = "";
client.gatewayUrl = "http://sandbox.wangdian.cn/openapi2/api_goodsspec_push.php";
var api_goods_info = new
{
platform_id = "127",
shop_no = "octmami",
goods_list = new[]
{
new
{
goods_id="6543217612345",
spec_id = "732176432",
goods_no = "myxx",
spec_no = "myxx",
status = "1"
},
new
{
goods_id="87654123787",
spec_id = "45687654",
goods_no = "dshg",
spec_no = "dshg",
status = "1"
},
new
{
goods_id="87654322355",
spec_id = "234567876",
goods_no = "mhgs",
spec_no = "mhgs",
status = "1"
}
}
};
string json = api_goods_info.ToJsonString();
client.putParams("api_goods_info", 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/')
api_goods_info = {}
goods_list = []
goods_1 = {}
goods_1.update({"goods_id": 'goods_id123'})
goods_1.update({"spec_id": 'spec_id123'})
goods_1.update({"goods_no": '123'})
goods_1.update({"spec_no": '123'})
goods_1.update({"status": '1'})
goods_1.update({"goods_name": '平台商品'})
goods_1.update({"spec_code": '123456'})
goods_1.update({"spec_name": '规格名称'})
goods_1.update({"price": '10'})
goods_1.update({"stock_num": '1'})
goods_list.append(goods_1)
api_goods_info.update({"platform_id": '127'})
api_goods_info.update({"shop_no": 'test2-test'})
api_goods_info.update({"goods_list": goods_list})
jsonArr = json.dumps(api_goods_info, ensure_ascii=False)
params = {}
params.update({"api_goods_info": jsonArr})
response = t.execute("api_goodsspec_push.php", params)
print(response) |