Web services in Magneto

August 10th, 2012 by Laeeq | No comments

magento_ecommerce_web services

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.

  1. http://yourmagentohost/api/soap/?wsdl

Below is the complete example which shows how to make SOAP calls:

  1. $client = new SoapClient(‘http://yourmagentohost/soap/api/?wsdl’);
  2. //  provide api authentification,
  3. $session = $client->login(‘apiUser’, ‘apiKey’);
  4. $result = $client->call($session, ‘api_method’);
  5. $result = $client->call($session, ‘api_method’, ‘parameter1′);
  6. $result = $client->call($session, ‘api_method’, array(‘parameter1′, ‘parameter2′, ‘parameter3′));
  7. $result = $client->multiCall($session, array(
  8. array(‘api_method’),
  9. array(‘api_method’, ‘parameter1′),
  10. array(‘api_method’, array(‘parameter1′, ‘parameter2′))
  11. ));
  12. $client->endSession($session);

XML-RPC Web API call  in Magento

You can use below URL into your XML-RPC client to load XML-RPC:

  1. http://magentohost/api/xmlrpc/

Below is the complete example which shows how to make XML-RPC calls:

  1. $client = new Zend_XmlRpc_Client(‘http://magentohost/api/xmlrpc/’);
  2. // provide api authentification,
  3. $session = $client->call(‘login’, array(‘apiUser’, ‘apiKey’));
  4. $client->call(‘call’, array($session, ‘api_method’, array(‘parameter1′, ‘parameter2′, ‘parameter3′)));
  5. $client->call(‘call’, array($session, ‘api_method’, ‘parameter1′));
  6. $client->call(‘call’, array($session, ‘api_method’));
  7. $client->call(‘multiCall’, array($session,
  8. array(
  9. array(‘somestuff.method’, ‘parameter1′),
  10. array(‘somestuff.method’, array(‘parameter1′, ‘parameter2′)),
  11. array(‘somestuff.method’)
  12. )
  13. ));
  14. $client->call(‘endSession’, array($session));

You can subscribe to PHPZAG.COM posts by Email

 

Related Topics:

 

 

  1. No comments yet.
  1. No trackbacks yet.