Php Flow » Magento, Php

How to call Magento web Api with help of PHP SOAP client

Call webservice in magnto is very easy its only 3 step process ,First we create the soap client with hekp of Soap api url then generate session with username and password,Finally we ar ble to call all webservice method From Soap Webservice Api.

  1. <?php  
  2.   
  3. /* 
  4.  * @created by          : Parvez Alam */  
  5. //disables  the soap catch .Its also handled from php.ini file.  
  6. ini_set(“soap.wsdl_cache_enabled”“0″);  
  7. //creating the soap client with help of Api URL  
  8. $client = new SoapClient(“http://localhost/magento/index.php/api/?wsdl”);  
  9. //login with webservice username and password  
  10. $session = $client->login(“username”“password”);  
  11. try{  
  12. //call the webservice method  
  13. $result1=$client->call($session‘sales_order.getTicketPrice’array());  
  14. //Note:sales_order is resource name which is define in api.xml  
  15. }catch (Exception $e)  
  16. {  
  17. echo $e->getMessage();  
  18. }  
  19. //echo $result1;   
  20. //var_dump($client->call($session, ’category.tree’));  
  21. echo “<pre>”;  
  22. //print_r($result);  
  23. if(isset($result1))  
  24. {  
  25. print_r($result1);  
  26. }  
  27. echo “<pre>”;  
  28. ?>  

Did you enjoy this article? Share it!

About the Author:

Hi, This is Parvez Alam from India. I am software developer with 4 years’ experience in web development. I have submitted articles on PHP, Mysql, Magento,CSS, HTML, jQuery, web designing and social API. You can subscribe to my blog via RSS/Twitter/Google plus and Facebook.

Also like

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>