I am using the Zend Framework and using Zend_Http_Client
to make a POST request to a third party API.
$client = new Zend_Http_Client('http://api.com');
$client->setParameterPost(array(
'param1' => 'value'
));
$response = $client->request('POST');
echo $response->getBody();
This API returns an XML document as its response.
<?xml version="1.0" ?>
<registration>
<id>12345</id>
</registration>
How can I turn the response into something I can work with?
I find the easiest way is to use SimpleXml
$data = simplexml_load_string($response->getBody());
Then, to get the ID, you can use
$id = (string) $data->registration->id;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With