$price = $_POST['price'];
$images = $_POST['images'];
$productData = [
"product" => [
"variants" => [
[
"price"=>"$price"
]
],
"images" => [
[
"src"=> "$images"
]
],
]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://{shop-name}.myshopify.com/admin/api/2022-10/products.json?access_token={access-token}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type' => 'application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($productData));
$response = curl_exec($ch);
echo'<pre>';
print_r($response);
echo'</pre>';
curl_close($ch);
我试图通过php-curl
发送我的产品详细信息,但当我发送它时,它显示了网站中的数据,但产品的图像和价格没有显示在它,它没有显示任何类型的错误。
1条答案
按热度按时间qnakjoqk1#
请使用此选项:
参考文献:https://shopify.dev/api/admin-rest/2022-10/resources/product#post-products