Posting XML with PHP using Zend Framework HTTP Client

PHP
2022-04-20 00:34 (3 years ago)
Posting XML with PHP using Zend Framework HTTP Client

Here is the code to construct XML using SimpleXML in PHP and send a request using Zend Framework's HTTP Client:

$xml = new \SimpleXMLElement('<request/>');
$xml->addChild(
'partner',
$this->credentials['aaa']);
$order = $xml->addChild('order');
$order->addAttribute('order_id', $orderId);
$order->addChild('status', $status);

$client = new \Zend_Http_Client();
$client->setUri('https://....');
$client->setRawData($xml->asXML(), 'text/xml');
$response =
$client->request('POST');

Please rate this article
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Categories

Archive