I'm using the following function to send data to a particular API.
function api_post($xml) {
$ch = curl_init('http://api.asmx');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml;charset=UTF-8"));
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
$results = curl_exec($ch);
return $results;
}
The output is
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LoadResponse xmlns="http://api.api.com/">
<LoadResult>
<date>2015-09-18T10_07_51.997</date>
<data><br>⢠bullet1<br>⢠Bullet2</data>
</LoadResult>
</LoadResponse>
</soap:Body>
</soap:Envelope>
The results returned are as expected except that bullet points are returned as â¢
and date values as 2015-09-18T10_07_51.997
instead of 2015-09-18T10:07:51.997
.
When I test out the same API call with the same XML in Soap UI everything is returned accurately. I'm assuming I have some kind of encoding issue in PHP. How can I resolve?
• text` – user2029890 Oct 11 '15 at 19:35
â¢` – user2029890 Oct 11 '15 at 19:48