我想用shopify api創建產品,但產品沒有設置,我沒有得到任何錯誤。 print_r($server_output);
什麼都不顯示,所以我看不出我錯在哪裏。捲曲也被啓用。以下是我使用的代碼。
當我print_r($products);
它顯示陣列應該如何。難道我做錯了什麼?正確shopify api產品創建
$name='test product 555';
$group=36;
$quantity=20;
$price='20.95';
$url = 'https://my_key_and_pass/admin/products.json';
$type = 'POST';
$product = array('title' => utf8_encode($name),
'body_html' => utf8_encode($name),
'product_type'=> $group,
'variants' => array(
array('price' => $price,
'inventory_quantity'=> $quantity,
'inventory_management' => 'shopify'
)
)
);
$ch = curl_init($url);
$data_string = json_encode(array('product'=>$product));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$server_output = curl_exec ($ch);
print_r($server_output);
curl_close ($ch);
的問題是,我不清楚。也許描述你的期望,而你取而代之? – kebs
您應該改用node.js。 –
哈!用於業餘愛好者的螺桿node.js。改用Fortran併成爲一個真正的人。這些人使用貓腳本語言... pffft。 –