Я могу успешно выполнить PHP POST для API-интерфейса NodeJS, который возвращает
ответ от NodeJS
res.json({status:'ok',submission_id:id});
Но я не могу правильно проанализировать ответ, возвращается NULL
// $newRequired = a complete array
$host = 'https://URL_HERE';
$json = json_encode($newRequired);
$ch = curl_init($host);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json',
'Content-Length: ' . strlen($json))
);
$response = curl_exec($ch);
$var = json_decode($response, true);
var_dump($var);
Ответ, если я просто echo $response
на страницу выглядит следующим образом
HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Sun, 27 Jan 2019 05:55:30 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 34
Connection: keep-alive
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE, OPTIONS
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
ETag: W/"XXXXXXX"
{"status":"ok","submission_id":83}
Я хотел бы получить доступ к значению submission_id из ответа в PHP