utpal4job Posted September 14, 2013 Share Posted September 14, 2013 Hello, I have installed the prestashop on my server. Now i want to use prestashop web service. Below are the codes which i am using to retrieve customer list but when running the code i always getting "Other error" message. Please help me how to solve this issue. ========================================================================= define('DEBUG', true); // Debug modedefine('PS_SHOP_PATH', 'https://vx44.com/prestashop/'); // Root path of your PrestaShop storedefine('PS_WS_AUTH_KEY', '*********************************'); // Auth key (Get it in your Back Office)require_once('../PSWebServiceLibrary.php');// Here we make the WebService Calltry{ $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); // Here we set the option array for the Webservice : we want customers resources $opt['resource'] = 'customers'; // Call $xml = $webService->get($opt); // Here we get the elements from children of customers markup "customer" $resources = $xml->customers->children();}catch (PrestaShopWebserviceException $e){ // Here we are dealing with errors $trace = $e->getTrace(); if ($trace[0]['args'][0] == 404) echo 'Bad ID'; else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; else echo 'Other error';}// We set the Titleecho "<h1>Customer's List</h1>";echo '<table border="5">';// if $resources is set we can lists element in it otherwise do nothing cause there's an errorif (isset($resources)){ echo '<tr><th>Id</th></tr>'; foreach ($resources as $resource) { // Iterates on the found IDs echo '<tr><td>'.$resource->attributes().'</td></tr>'; }}echo '</table>'; ================================================================= Regards. Link to comment Share on other sites More sharing options...
juancamba Posted April 9, 2015 Share Posted April 9, 2015 Hello! I've got the same problem and I don't know what's the problem because if i type the url in a browser can I see the xml: <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <api shopName="prestashop-local"> <customers xlink:href="http://prestashop.local/api/customers" get="true" put="true" post="true" delete="true" head="true"> <description xlink:href="http://prestashop.local/api/customers" get="true" put="true" post="true" delete="true" head="true">The e-shop's customers</description> <schema xlink:href="http://prestashop.local/api/customers?schema=blank" type="blank"/> <schema xlink:href="http://prestashop.local/api/customers?schema=synopsis" type="synopsis"/> </customers> </api> </prestashop> Mi configuration is 2 virtual hosts one to provide the prestashop page called prestashop.local with the webservices acitivated and another one called pruebas.local to test the web service. Like this: <VirtualHost *:80> ServerName pruebas.local ServerAlias www.pruebas.local DocumentRoot "C:\Users\juancamba\Documents\php\pruebas.local" <Directory C:\Users\juancamba\Documents\php\pruebas.local> DirectoryIndex index.php AllowOverride All Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerName prestashop.local ServerAlias www.prestashop.local DocumentRoot "C:/Users/juancamba/Documents/php/prestashop.local" <Directory C:/Users/juancamba/Documents/php/prestashop.local> DirectoryIndex index.php AllowOverride All Require all granted </Directory> </VirtualHost> Thanks Link to comment Share on other sites More sharing options...
Recommended Posts