Child pages
  • Chapter 3 - First steps - Access the Web service and list client

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • The store's root path (ex: http://myprestashopexample.com/ ).
  • The authentication key (ex: ZR92FNY5UFRERNI3O9Z5QDHWKTP3YIIT).
  • A boolean value, indicating whether the Web service must use its debug mode.

...

Code Block
$webService = new PrestaShopWebservice('http://myprestashopexample.com/', 'ZR92FNY5UFRERNI3O9Z5QDHWKTP3YIIT', false);

...

  1. In the try block, we instantiate the PrestaShopWebservice object with the necessary parameters and retrieve the customer resource XML in a variable.
  2. In the catch block, we put code to display the PHP error message, if anything wrong happens in the try block.
Code Block
try {
	// creating web service access
	$webService = new PrestaShopWebservice('http://maboutiqueexample.com/', 'ZR92FNY5UFRERNI3O9Z5QDHWKTP3YIIT', false);

	// call to retrieve all clients
	$xml = $webService->get(array('resource' => 'customers'));
}
catch (PrestaShopWebserviceException $ex) {
	// Shows a message related to the error
	echo 'Other error: <br />' . $ex->getMessage(); 
}

...

Launching the code above will return a *impleXML SimpleXML object containing all the client IDs.

...

Thanks to these elements, we can create a HTML table containing all the client IDs. Try that before reading the next chapter.

You can use the "CcustomersCustomers" menu in the back-office to find the IDs of all customers. If you encounter difficulties, have a look at the example file named 0-CustomersList.php, to see the results you should get.