When you have got to test your Magento API Methods, it can be complicated. One day, I had to create/modify API method on Magento, these methods were used on iPad. Without an iPad, I create a little script in order to simulate API calls.
First, create an user on Magento Admin Panel :
System -> Webservices -> Users
System -> Webservices -> Roles
After, create a PHP file on your local server (I put it on the root with the name “webservicesV1.php”) :
<h1>Webservice Test</h1> <?php ini_set('display_errors', 1); error_reporting(E_ALL ^ E_NOTICE); if(!empty($_POST['login']) && !empty($_POST['mdp']) && !empty($_POST['fonction'])){ $client = new SoapClient('http://www.mysite.com/api/?wsdl=1'); $session = $client->login($_POST['login'], $_POST['mdp']); if(empty($_POST['params'])){ $result = $client->call($session, $_POST['fonction']); // he we execute the command using that data we provided } else { $params = explode('|',$_POST['params']); $result = $client->call($session, $_POST['fonction'], $params); // he we execute the command using that data we provided } print '<div style="padding:10px;background:#D1D1D1;margin-left:20px;margin-right:20px;margin-bottom:10px;">'; print 'Command Result <b>'.$_POST['fonction'].'</b><br />'; print 'Parameters : <b>'.str_replace('|',', ',$_POST['params']).'</b><br />'; print '<pre>'; print_r($result); print '</pre>'; print '</div>'; $client->endSession($session); } ?> <fieldset style="margin-left:20px;margin-right:20px;"> <legend>Informations</legend> <form action="webservicesV1.php" method="post"> Login* : <input type="text" name="login" value="<?php echo $_POST['login'] ?>"/><br /> Password* : <input type="password" name="mdp" value="<?php echo $_POST['mdp'] ?>" /><br /> Method* : <input type="text" name="fonction" value="<?php echo $_POST['fonction'] ?>" /><br /> Parameter(s) : <input type="text" name="params" value="<?php echo $_POST['params'] ?>" /> (Separator : "|")<br /> <input type="submit" value="Testing !" /> </form> </fieldset>
For security, this script is on my local server, the most important is to call the right webservice :
new SoapClient('http://www.mysite.com/api/?wsdl=1');
You put your login, password, the function to execute, parameters if exists. If you’ve got many parameters, use “|” separator each one.
Easily Test API V1 Magento