Web services in Magneto
In my previous post, you have learned how to Magento – Models, resource models, and collections and about Display Related products on product details page in Magento . Here in this post you will know about MagnetoWeb services.
Magento is a award winning e-commerce solution which provides extensive module-based functionality, including online shop management, catalogue and product management, marketing and promotional tools, eCommerce SEO, secure and easy to use shopping carts, mobile eCommerce, web service api and product browsing.
Magento web services api provides you with the ability to manage your eCommerce stores by providing calls for working with resources such as customers, categories, products, and sales orders. It also allows you to manage shopping carts and inventory.
Magento supported Web API
The Magento API supports both SOAP and XML-RPC.
SOAP Web API Call in Magento
The SOAP is the default service with Magento. you need to use WSDL into your SAOP client to make connection to Magento SOAP web services. use below url to connect SOAP.
- http://yourmagentohost/api/soap/?wsdl
Below is the complete example which shows how to make SOAP calls:
- $client = new SoapClient(‘http://yourmagentohost/soap/api/?wsdl’);
- // provide api authentification,
- $session = $client->login(‘apiUser’, ‘apiKey’);
- $result = $client->call($session, ‘api_method’);
- $result = $client->call($session, ‘api_method’, ‘parameter1′);
- $result = $client->call($session, ‘api_method’, array(‘parameter1′, ‘parameter2′, ‘parameter3′));
- $result = $client->multiCall($session, array(
- array(‘api_method’),
- array(‘api_method’, ‘parameter1′),
- array(‘api_method’, array(‘parameter1′, ‘parameter2′))
- ));
- $client->endSession($session);
XML-RPC Web API call in Magento
You can use below URL into your XML-RPC client to load XML-RPC:
- http://magentohost/api/xmlrpc/
Below is the complete example which shows how to make XML-RPC calls:
- $client = new Zend_XmlRpc_Client(‘http://magentohost/api/xmlrpc/’);
- // provide api authentification,
- $session = $client->call(‘login’, array(‘apiUser’, ‘apiKey’));
- $client->call(‘call’, array($session, ‘api_method’, array(‘parameter1′, ‘parameter2′, ‘parameter3′)));
- $client->call(‘call’, array($session, ‘api_method’, ‘parameter1′));
- $client->call(‘call’, array($session, ‘api_method’));
- $client->call(‘multiCall’, array($session,
- array(
- array(‘somestuff.method’, ‘parameter1′),
- array(‘somestuff.method’, array(‘parameter1′, ‘parameter2′)),
- array(‘somestuff.method’)
- )
- ));
- $client->call(‘endSession’, array($session));
Follow @phpzag

