使用 curl php 删除 shopify 价格规则
Delete shopify price rule using curl php
我正在尝试删除通过 API 创建的价格规则。 Create API 工作正常,但不知何故 delete 不起作用。这是我的代码
$shop = "my-shopify-shop";
$token = "1321312312312321311";
$api_endpoint="/admin/api/2020-01/price_rules/#627965853827.json";
$url = "https://" . $shop . ".myshopify.com" . $api_endpoint;
$header=array('Content-Type: application/json','Authorization:Basic Og==','X-Shopify-Access-Token: ' .$token);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER,$header);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST,"DELETE");
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec ($curl);
if (curl_errno($curl)) {
die('Couldn\'t send request: ' . curl_error($curl));
}
curl_close ($curl);
print_r($response);
我得到这样的输出
我错过了什么?谁能推荐一下?
终于找到解决办法了,
我删除了规则 ID 之前的#,这是我的端点
$api_endpoint="/admin/api/2020-01/price_rules/#627965853827.json";
但应该是
$api_endpoint="/admin/api/2020-01/price_rules/627965853827.json";
希望这对以后的人有所帮助
我正在尝试删除通过 API 创建的价格规则。 Create API 工作正常,但不知何故 delete 不起作用。这是我的代码
$shop = "my-shopify-shop";
$token = "1321312312312321311";
$api_endpoint="/admin/api/2020-01/price_rules/#627965853827.json";
$url = "https://" . $shop . ".myshopify.com" . $api_endpoint;
$header=array('Content-Type: application/json','Authorization:Basic Og==','X-Shopify-Access-Token: ' .$token);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER,$header);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST,"DELETE");
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec ($curl);
if (curl_errno($curl)) {
die('Couldn\'t send request: ' . curl_error($curl));
}
curl_close ($curl);
print_r($response);
我得到这样的输出
我错过了什么?谁能推荐一下?
终于找到解决办法了,
我删除了规则 ID 之前的#,这是我的端点
$api_endpoint="/admin/api/2020-01/price_rules/#627965853827.json";
但应该是
$api_endpoint="/admin/api/2020-01/price_rules/627965853827.json";
希望这对以后的人有所帮助