pablodalma93 Posted January 27, 2014 Share Posted January 27, 2014 Hi newbie here, Im trying the tutorial for using the Prestashop Webservice, when running the code for creating a HTML table containing all the client IDs of chapter 3 it works , but when trying to get a specific customer data with the following code it gives a "Node no longer exists in" PHP warning , but I know a customer with that id exists from the former chapter $opt['resource'] = 'customers'; $opt['id'] = $_GET['id']; $xml = $webService->get($opt); $resources = $xml->customers->children(); foreach ($resources as $key => $resource) echo 'Name of field: ' . $key . ' - Value: ' . $resource . '<br />'; also tried replacing $_GET['id'] with $opt['id'] = 1; or $opt['id'] = '1'; Link to comment Share on other sites More sharing options...
salbrech Posted November 11, 2014 Share Posted November 11, 2014 (edited) Hi I just expecting the same issue and I founded a solution: Juste replace $resources = $xml->customers->children(); By $resources = $xml->customer->children(); (Remove "s" from the end of customerS) Here is my working code: <?php require_once('./PSWebServiceLibrary.php'); $cusId = '2'; try { // creating web service access $webService = new PrestaShopWebservice('http://example.com/', 'ZR92FNY5UFRERNI3O9Z5QDHWKTP3YIIT', false); // The key-value array $opt = array('resource' => 'customers', 'id' => $cusId); // call to retrieve all customers $xml = $webService->get($opt); $resources = $xml->customer->children(); foreach ($resources as $key => $resource) { echo 'Name of field: ' . $key . ' - Value: ' . $resource . chr(10); } } catch (PrestaShopWebserviceException $ex) { // Shows a message related to the error echo 'Other error: <br />' . $ex->getMessage(); } ?> Edited November 11, 2014 by salbrech (see edit history) Link to comment Share on other sites More sharing options...
salbrech Posted November 11, 2014 Share Posted November 11, 2014 (edited) By the way you can use $resources = $xml->children()->children(); as well. Edited November 11, 2014 by salbrech (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now