Posting XML with PHP using Zend Framework HTTP Client

PHP
2022-04-20 09:34 (2 years ago) ytyng

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');

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

Archive

2025
2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011