[英]Using cURL to update inventory in BigCommerce
我正在使用以下代码通过Amazon清单中的新库存编号来更新bigcommerce中的产品-完美适用于没有选项集的任何产品(特别是手套和衬衫,显然每个S,M都有单独的库存水平,L)。
$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-有什么想法吗?
我可能会遗漏一些东西,但似乎您没有告诉api您要指的是哪个选项,因此它无法正确回复,结果是404。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.