Child pages
  • Chapter 4 - Retrieve Data - Retrieving a Client

Versions Compared

Key

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

...

In the XML data that we retrieved, which contains the list of clients, we will find all the XLinks providing access to customer information.

Code Block

<customers>
	<customer id="1" xlink:href="http://myprestashopexample.com/api/customers/1" />
</customers>

...

The XLink for the customer tag with ID 1 is: http://myprestashopexample.com/api/customers/1

This link retrieves a new XML file, which contains information about the client who has ID 1.

In order to manage access to different clients, we will associate page identifiers with customers via a GET parameter named "id". The link http://myprestashopexample.com/R-CRUD.php?id=1 we will display the file for customer 1.

...

Currently, we are using the customers or clients resources. If we'd been trying to change the countries resources, this ID would have been a country ID.

Code Block

$opt['resource'] = 'customers';
$opt['id'] = $_GET['id'];
$xml = $webService->get($opt);

...

Accessing resources is performed as above for displaying the list, because the tags that interest us are children of the customers tag.

Code Block

$resources = $xml->customers->children();

This path can be created in another way (here in an HTML table):

Code Block

foreach ($resources as $key => $resource)
	echo 'Name of field: ' . $key . ' - Value: ' . $resource . '<br />';

...