What exactly is not working for you?
I think you have to first try parts out. Is the content of the response in proper XML? What does simplexml_load_string return for you?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I am trying to get a response from an old asp API that returns XML data and convert it into JSON and although I am getting a response it is not formatting and outputting JSON. Can anyone suggest a solution to this issue or what I am doing wrong?
public function getSupercontrolDetails()
{
$client = new Client();
$response = $client->request('GET', 'https://api.supercontrol.co.uk/xml/property_xml.asp?id=94298&siteID=14978', [
'headers' => [
'Accept' => 'text/xml'
]
]);
if ($response->getStatusCode() == 200) {
$response = json_encode(simplexml_load_string($response->getBody()->getContents()));
}
dd($response);
}
Please or to participate in this conversation.