文档中心 > API类目 > 商�货�API

dsc.product.insert.post (�入商�货�信�API)�默认模�】

�入货�信�API,获�货�相关信�。

公共�数

请求地�:
环境 HTTP请求地� HTTPS请求地�
正�环境 http://www.xxx.com/api.php https://www.xxx.com/api.php
公共请求�数:
�称 类型 是�必须 �述
method String 是 API接��称
app_key String 是 API接�AppKey

请求�数

�称 类型 是�必须 示例值 更多�制 �述
data array 必须 array('goods_id' => 154, 'goods_attr' => '519|528', 'product_sn' => '154HP0001', 'bar_code' => '154BAR0001', 'product_number' => 999) 转为JSON或XML 更新�数
format type 必须 json json或xml 接�类型

�应�数

�称 类型 示例值 �述
product_id Number 货�ID
goods_id Number 商�ID
goods_attr String 519|528 属性ID�称(ID值拼接格�:519|528)
product_sn String 货�编�
bar_code String 货��形�
product_number Number 货�库存
product_price float 货�价格
product_promote_price float 货�促销价
product_market_price float 货�市场价格
product_warn_number Number 货�警告库存

请求示例

  • PHP(jsonæ ¼å¼�)
  • PHP(xmlæ ¼å¼�)
$url="http(s)://www.xxx.com/api.php?app_key=A788F457-1A7D-4CC7-ABA0-BFE212BCCD9A&method=dsc.product.insert.post&format=json"
$Http = new Http();
 
$data=array(
<goods_id>154</goods_id>
<goods_attr>519|528</goods_attr>
<product_sn>154HP0001</product_sn>
<bar_code>154BAR0001</bar_code>
<product_number>999</product_number>
<product_price>167.54</product_price>
<product_promote_price>146.2</product_promote_price>
<product_market_price>300</product_market_price>
<product_warn_number>20</product_warn_number>
)
 
$data = json_encode($data); // 对��进行 JSON 编�
$argument=array(
'data' => $data
)
 
$Http->doPost($url, $argument);
$url="http(s)://www.xxx.com/api.php?app_key=A788F457-1A7D-4CC7-ABA0-BFE212BCCD9A&method=dsc.product.insert.post&format=xml"
$Http = new Http();
 
$data = '<?xml version="1.0" encoding="utf-8"?>
<dsc>
"goods_id": "154",
"goods_attr": "519|528",
"product_sn": "154HP0001",
"bar_code": "154BAR0001",
"product_number": "999",
"product_price": "167.54",
"product_promote_price": "146.2",
"product_market_price": "300",
"product_warn_number": "20",
</dsc>';
 
$data = htmlspecialchars($data); // 将特殊字符转�为 HTML 实体
$argument = array(
'data' => $data
);
 
$Http->doPost($url, $argument);

异常示例

  • XML
  • JSON
<dsc>
<result>success</result>
<error>0</error>
<msg>数��交�功</msg>
</dsc>
{
"result": "success",
"error": 0,
"msg": "数��交�功",
}

错误�解释

错误� 错误�述 解决方案
error 返回值

0:数��交�功

1:数��交失败,�数�存在

2:存在��传�的�数

3:已存在相�数�,无法添加

4:关键�数�存在或值为空

返回
顶部