首页 > 解决方案 > 错误:titled_product_ids:expected Hash to be a Array(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"
    }
}

标签: phpshopify

解决方案


推荐阅读