我正在尝试通过api发布一次Shopify,一次包含多个图片/变体。 我目前正在使用guzzle php,这有效:
$response = $shop->api()->rest('POST', '/admin/products/#{productnumber}/images.json' ,[
"image" => [
"src" => "https://example.com/images/blahblah.jpg",
"variant_ids" => ["9999999999"]
]
但是我需要做多个,所以我试图做这样的事情:
$response = $shop->api()->rest('POST', '/admin/products/#{productnumber}/images.json' ,[
"image" => [
"src" => "https://example.com/images/blahblah.jpg",
"variant_ids" => ["9999999999"]
],
"image" => [
"src" => "https://example.com/images/blahblah.jpg",
"variant_ids" => ["9999999999"]
]
以上操作无效。也不起作用:
$response = $shop->api()->rest('POST', '/admin/products/#{productnumber}/images.json' ,[
"image" => [
"src" => "https://example.com/images/blahblah.jpg",
"variant_ids" => ["9999999999"],
"src" => "https://example.com/images/blahblah.jpg",
"variant_ids" => ["9999999999"]
]
我可以遍历每个图像和变体,但我试图避免必须进行多次调用。请让我知道。谢谢!
答案 0 :(得分:1)
我认为您将不得不使用GraphQL并尝试在那里进行突变以添加图像阵列。 RestAPI是一招的小马,每个图片似乎只有一个调用。我浏览了所有旧代码,并始终为每个图像刻录API调用。
GraphQL具有images []的概念,所以看来这是最好的选择。