'Hi from PHP!'); $request1 = json_encode($msg); $curl = curl_init('http://localhost:8001/msgs'); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json')); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $request1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response1 = curl_exec($curl); curl_close($curl); $curl = curl_init('http://localhost:8001/msgs'); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json')); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response2 = curl_exec($curl); curl_close($curl); $msgs = json_decode($response2); foreach($msgs->message as $msg) { echo $msg->text . "\r\n"; } ?>