PHP Guzzlehttp Request Result for html table

Asked

Viewed 61 times

1

I need to export the result of a Guzzlehttp request to the html table. I’m having trouble turning the output "$res" into the correct format. Which function should I use to turn "$res" into the correct output? From now on, thank you.

Request:

$client = new \GuzzleHttp\Client();
$res = $client->post($url, ['body' => $xml, 'headers' => ['Content-Type' => 'application/json']])->getBody();

$data = array_map(utf8_encode($res), $res);
echo json_encode($data);


$data output (Exception):

(1/1) ErrorException
array_map() expects parameter 1 to be a valid callback, function '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ser-root:getErrorResponse xmlns:ser-root="http://**********/*****/ws/********">
<StatusCode>0</StatusCode>
<Status_id>SUCCESS</Status_id>
<Results>
<id>2434242</id>
<other_id>63478648</other_id>
<message>id not valid</message>
</Results>
<Results>
<id>5435354</id>
<other_id>2553454563</other_id>
<message>id not valid</message>
</Results>
</ser-root:getErrorResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>' not found or invalid function name
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.