我想用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。 –