// 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<br />' . $e->getMessage(); } } } } else { // Else get customers list try { $webService = new WebService(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $opt = array('resource' => 'customers'); $xml = $webService->get($opt); $resources = $xml->children()->children(); } catch (\PrestaShop\WebServiceException $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'; } }
* * @author PrestaShop SA <*****@*****.**> * @copyright 2007-2013 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA * PrestaShop Webservice Library * @package PrestaShopWebservice */ // Here we define constants /!\ You need to replace this parameters use PrestaShop\WebService; define('DEBUG', true); define('PS_SHOP_PATH', 'http://www.myshop.com/'); define('PS_WS_AUTH_KEY', 'ZQ88PRJX5VWQHCWE4EE7SQ7HPNX00RAJ'); // Here we use the WebService to get the schema of "customers" resource try { $webService = new WebService(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $opt = array('resource' => 'customers'); if (isset($_GET['Create'])) { $xml = $webService->get(array('url' => PS_SHOP_PATH . '/api/customers?schema=blank')); } else { $xml = $webService->get($opt); } $resources = $xml->children()->children(); } catch (\PrestaShop\WebServiceException $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';