错误:titled_product_ids:预期哈希为数组(Shopify嵌入式应用程序)

时间:2019-02-21 06:37:54

标签: php shopify

我正在通过cURL发送以下请求,一切正常,但是“ entitled_product_id”存在错误。它适用于邮递员,但不适用于cURL。

谢谢。

cURL请求代码为

$ch = curl_init();    
curl_setopt($ch, CURLOPT_URL, $access_token_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($pro_ids11));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Shopify-Access-Token: '.$shops_token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
if (curl_error($ch)) {
    $error_msg = curl_error($ch);
}
curl_close($ch);
if (isset($error_msg)) {
    echo $error_msg;
}

我的json_encoded代码为:

{
  "price_rule":
  {
    "title":"sad",
    "target_type":"line_item",
    "target_selection":"entitled",
    "allocation_method":"across",
    "value_type":"percentage",
    "value":"-3",
    "customer_selection":"all",
    "prerequisite_quantity_range":{"greater_than_or_equal_to":"2"},
    "entitled_product_ids":["2389482225165"],
    "starts_at":"2019-02-20T11:37:57.000Z"
  }
}

回复:

{
  "errors":
    {
      "entitled_product_ids":"expected Hash to be a Array"
    }
}

0 个答案:

没有答案