我发送了一个curl请求,并以这种方式输出响应。
$output = curl_exec($ch);
$json = json_decode($output, true);
echo $output;
echo $json;这是输出。
HTTP/1.1 201 Created Server: nginx/1.15.8 Date: Wed, 02 Sep 2020 23:53:01 GMT Content-Type: application/json Transfer-Encoding: chunked Connection: keep-alive X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: 0 X-Frame-Options: DENY Strict-Transport-Security: max-age=31536000; includeSubdomains { "orderRef" : "4352fa96-05cc-400e-854c-808e5da7dfd7", "autoStartToken" : "84ead0b7-1ee8-40ed-be82-1168e7cbb16b", "message" : "" }我正在尝试解码json部分,但是$json是空的。我希望能够读懂$json"autoStartToken“。我将如何实现这一点?
发布于 2020-09-03 08:22:47
现在,您的curl请求也返回报头,因此您不能直接将json_decode用于响应,请尝试将curl_setopt($ch, CURLOPT_HEADER, 0);放在curl_exec($ch)之前
https://stackoverflow.com/questions/63714989
复制相似问题