Shopify PUT code into layout/theme with assets rest api
Shopify PUT code into layout/theme with assets rest api
我正在尝试 post 进入我的 theme.liquid 文件,但它给出了 404 错误,我可以使用 get 方法找到资产,但 post 没有工作,这是我的代码有什么建议吗?
$response = $shop->api()->rest('POST', '/admin/api/202110/themes/128946634999/assets.json',
[ "asset" => [
"key" => "layout/theme.liquid",
"value" => "<p>This is a test API upload.</p>"
]
]);
你可以试试这个代码
$param = [
'asset'=>[
"key" => "layout/theme.liquid",
"value" => "<p>This is a test API upload.</p>"
]
];
$response = $shop->api()->rest('put','/admin/api/2021-10/themes/128946634999/assets.json',$param);
我想出了如何插入 layout/theme.liquid 文件,我发现你需要同时拥有 {{ content_for_header }} 和 {{ content_for_layout }}在 shopify 识别之前的字符串中。
$param = [
'asset'=>[
"key" => "layout/theme.liquid",
"value" => "{{ content_for_header }} TEST {{ content_for_layout }}"
]
];
$response = $shop->api()->rest('put','/admin/api/2021-10/themes/128946634999/assets.json',$param);
我正在尝试 post 进入我的 theme.liquid 文件,但它给出了 404 错误,我可以使用 get 方法找到资产,但 post 没有工作,这是我的代码有什么建议吗?
$response = $shop->api()->rest('POST', '/admin/api/202110/themes/128946634999/assets.json',
[ "asset" => [
"key" => "layout/theme.liquid",
"value" => "<p>This is a test API upload.</p>"
]
]);
你可以试试这个代码
$param = [
'asset'=>[
"key" => "layout/theme.liquid",
"value" => "<p>This is a test API upload.</p>"
]
];
$response = $shop->api()->rest('put','/admin/api/2021-10/themes/128946634999/assets.json',$param);
我想出了如何插入 layout/theme.liquid 文件,我发现你需要同时拥有 {{ content_for_header }} 和 {{ content_for_layout }}在 shopify 识别之前的字符串中。
$param = [
'asset'=>[
"key" => "layout/theme.liquid",
"value" => "{{ content_for_header }} TEST {{ content_for_layout }}"
]
];
$response = $shop->api()->rest('put','/admin/api/2021-10/themes/128946634999/assets.json',$param);