...
- Configure your PHP installation so that it has the cURL extension installed and activated:
With Windows: Place this line in your
php.ini
file:Code Block extension=php_curl.dll
Linux/Mac: install the cURL extension:
Code Block sudo apt-get install php5-curl
Copy the
PSWebServiceLibrary.php
file at the root of your Web server. You can download it from this URL: https://github.com/PrestaShop/PrestaShop-webservice-lib/archive/master.zipNote You can also do this tutorial on a local server even while your shop is on the Internet.
- Create a
list_the_clientscustomers.php
file at the root of the Web server that you have chosen. Specify where to find the web server in your file:
Code Block require_once( './ PSWebServiceLibrary.php' );
...
Code Block |
---|
try { // creating web service access $webService = new PrestaShopWebservice('http://example.com/', 'ZR92FNY5UFRERNI3O9Z5QDHWKTP3YIIT', false); // call to retrieve all clientscustomers $xml = $webService->get(array('resource' => 'customers')); } catch (PrestaShopWebserviceException $ex) { // Shows a message related to the error echo 'Other error: <br />' . $ex->getMessage(); } |
Listing
...
customers
Let's now see how to view a full list of client customer IDs. We could display more information and customize it, but that's for another part of this tutorial
...
Launching the code above will return a SimpleXML
object containing all the client customer IDs.
Code Block |
---|
<?xml> <prestashop> <customers> <customer> Clientcustomer ID </customer> <customer> Clientcustomer ID </customer> <customer> Clientcustomer ID </customer> ...Other clientcustomer tags </customers> </prestashop> |
...
The data returned by calling $webService->get
puts us at the root of the document.
To access the fields of clients customers who are children from the Customers tag, we only need to retrieve all fields in an associative array in SimpleXML like this:
...
From there, we can access client customer IDs easily. Here's an example with a path from identifiers:
...
Thanks to these elements, we can create a HTML table containing all the client customer IDs. Try that before reading the next chapter.
...