【发布时间】:2016-06-24 06:36:38
【问题描述】:
我正在尝试使用 Shopify Product API 将产品插入我的 Shopify 商店。
现在我可以插入产品数据以及产品的变体。
这是我的脚本
<?php
$name='test product 999';
$group=36;
$quantity=20;
$price='20.95';
$image = "http://clarks.scene7.com/is/image/clarks/26103666_A";
$url = "https://xxx:yyy@zzz.myshopify.com/admin/products.json";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
$type = 'POST';
$product = array('title' => utf8_encode($name),
'body_html' => utf8_encode($name),
'product_type'=> $group,
'vendor'=>'abc',
'id'=> '999',
"tags" => "Emotive, Flash Memory, MP3, Music",
"images"=>array ("src"=>'http://clarks.scene7.com/is/image/clarks/26103666_A'),
'variants' => array(
array('price' => $price,
'compare_at_price'=> $price,
'sku'=>'123gdjf',
'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_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
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);
?>
没有图像存储只有产品数据存储。 任何人都可以让我知道我错在哪里。或者我的脚本有什么问题。?
谢谢你
【问题讨论】: