我使用下面的代碼,以更新的產品與我們的亞馬遜上市的新庫存數據的Bigcommerce - 它完全適用於不具備的選項設置的任何產品(特別是手套和襯衫,這顯然每個S,M,L都有單獨的庫存水平)。使用捲曲在的Bigcommerce
$api_url = 'https://store-558hrkjw.mybigcommerce.com/api/v2/products/'.$nearrow['ProductID'].'.json';//put inventory
$StockdataRAW = array('inventory_level' => 500);//$nearrow['CurrentStockLevel']
$Stockdata = json_encode($StockdataRAW);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Content-type: application/json', 'Accept: application/json'));
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $Stockdata);
curl_setopt($ch, CURLOPT_USERPWD, "UID:PW");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Switch on verbose information and display it on the web page.
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, fopen('php://output', 'w+'));
$response = curl_exec($ch);
$result = json_decode($response);
print_r($result);
$info = curl_getinfo($ch);
curl_close($ch);
當我使用此代碼的選項我得到一個404每個產品ID - 任何想法?