Using Zend 2 XmlRpc library as Magento API client
Compatibility:The code presented in this article was tested with Magento Community Edition 184.108.40.206
In this article we will demonstrate how to use Zend 2 XmlRpc library as a client for Magento API.
Step 1 - downloading Zend 2
Go to the Zend website and download the latest code of the Zend 2 framework (I downloaded Zend Framework 2.3.1 Full). Extract the zip file, and copy the "library" folder to your web server.
Step 2 - connecting and using the Magento API
Create a php file with the following content:
$loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
$client = new Zend\XmlRpc\Client('http://www.my-magento-site.com/api/xmlrpc/');
$session = $client->call('login', array('apiusername', 'apipassword'));
$result = $client->call('call',array(
0 => array(
'created_at' => array(
'from' => '2014-04-01 00:00:00',
'to' => '2014-05-01 00:00:00'
- Replace "/path/to/zend/files/library" with the path of the "library" directory.
- Replace the http://www.my-magento-site.com with the name of your Magento url (the one which API you are connecting to), preferably replacing the "http" with "https".
- The API username and password are the ones that you set in Magento backend, in "System->Web Services->Soap/XML-RPC users".
- In this specific example, the code fetches an array of orders between 01/04/14 and 01/05/14 using Magento API. Change it for your needs ;-)