如何使用API​​更新Overstock.com上的库存

时间:2017-01-31 11:35:36

标签: php api curl

我尝试使用API​​更新supplieroasis.com上的库存。但是当api返回成功时,我没有得到https://edge.supplieroasis.com的更新。

我也想知道供应商绿洲如何为"保留"," sellable"," onHold"," totalQuantity"。

$user_pass = "XXXXXXXXXX:XXXXXXXXXX";
$header = array('Authorization: Basic '.base64_encode($user_pass),'Content-Type:application/xml');    
date_default_timezone_set("America/Denver");
$current_time  = mktime(date("H")-1, date("i"), date("s"), date("m")  , date("d"), date("Y"));
$inventory_at=  date("c",$current_time);    
$xml = <<<EOD
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<supplierInventoryMessage xmlns="api.supplieroasis.com">
<supplierInventory>
    <partnerSku>XXXXXXXXXXXXXXXXXXXX</partnerSku>
    <supplierWarehouseQuantity>
        <warehouseName>
            <code>XXXXXXXXXXX</code>
        </warehouseName>
        <quantity>13</quantity>
        <timestamp>$inventory_at</timestamp>            
    </supplierWarehouseQuantity>
</supplierInventory>    
</supplierInventoryMessage>
EOD;
$ch = curl_init();        
$url = 'https://api.supplieroasis.com/inventory?jobName=';

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT,150);
curl_setopt($ch, CURLOPT_CERTINFO, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch,CURLOPT_POST, TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS, $xml);
$str = curl_exec($ch);
if(!curl_errno($ch))
{
    $info = curl_getinfo($ch);
}
else
{
    echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
header("Content-Type:text/XML");
print_r($str);

0 个答案:

没有答案