私は次のコードを使用して、ビッグコマースの製品をAmazonリストから新しい在庫番号に更新します。オプションセットを持たない製品(特に手袋やシャツ。明らかに各S、M、Lについて別々の在庫レベルを有する)。BigCommerceの在庫を更新するためにcURLを使用します
$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);
このコードをオプションとして使用すると、製品IDごとに404が表示されます。