{
//// 提交的数据打印
"json": {
"order_key": {
"order_number_type": 2,
"transaction_id": "4200001900202309117405207277"
},
"logistics_type": 4,
"delivery_mode": 1,
"shipping_list": [
{
"item_desc": "金樽-窖藏1998"
}
],
"upload_time": "2023-09-11T16:28:21.000+08:00",
"payer": {
"openid": "o5z7w5DQVAaA2J3zheJh82Yo8mSs"
}
}
// 调用接口的结果
"result": "{\"errcode\":0,\"errmsg\":\"ok\"}",
}
您的JOSN不要编码中文就hao
用的啥电脑,我这边惠普暗影精灵2没问题
//// PHP GuzzleHttp客户端 发起请求
$client = new Client();
$clientHandler = $client->getConfig('handler');
$tapMiddleware = Middleware::tap(function ($request) {
$headerStr = $request->getHeader('Content-Type');
$bodyStr = $request->getBody()->getContents();
think_log('GuzzleHttp请求监听', [
'headerStr' => $headerStr, // 请求头;
'bodyStr' => $bodyStr, // 请求主题;
]);
});
$result = $client->request('POST', $url, [
'handler' => $tapMiddleware($clientHandler),
// 'json' => $postData, // 作为json提交,会自动对中文进行json_encode()编码;
'body' => json_encode($postData, JSON_UNESCAPED_UNICODE),
]);
$result = $result->getBody()->getContents();
think_log('uploadShippingInfo请求结果', ['result' => $result, 'json' => $postData, 'url' => $url]);