要把一个订单添加备注,同步到shopify:
//更新备注到shopify
$url = SHOPIFY_API_BASE . "orders/{$oid}.json";
$x_data = '{
"order":{
"note":"' . $note . '"
}
}';
$ret = CurlService::httpPutJson($url, $x_data);
结果返回错误:
{"error":"822: unexpected token at '{\r\n
\"order\":{
\r\n
\"note\":\"地址一致 但显示高风险, 等客人提供transaction details..\n\"\r\n
}\r\n
}'"}
原因是备注里面有换行符,
而用字符串的方式是没有对它转义的,改为json_encode的方式就ok了
$url = SHOPIFY_API_BASE . "orders/{$oid}.json";
$x_data = ['order'=>['note'=>$note]];
$x_data = json_encode($x_data);
$ret = CurlService::httpPutJson($url, $x_data);