【发布时间】:2016-06-13 22:49:46
【问题描述】:
我正在使用以下代码使用我们亚马逊列表中的新库存编号更新 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 - 有什么想法吗?
【问题讨论】:
标签: php curl bigcommerce inventory-management