Using the Tesco API with PHP

·

The Tesco API is barely documented and barely working, but you can do this:

<html>
<head>
  <meta http-equiv="content-type" content="text/html;charset=utf8">
  <title>Tesco Offers</title>
  <style>h2{font-size:100%} img{vertical-align:top} ul{list-style-type:none}</style>
</head>
<body>
<?php
$client = new SoapClient('http://www.lansley.com/TescoAPI/TescoAPI.svc?wsdl');         
$response = $client->Login(array(
  'email'  => 'YOUR_EMAIL_ADDRESS_FOR_TESCO.COM',
  'password' => 'YOUR_PASSWORD_FOR_TESCO.COM',
  'developerKey' => 'YOUR_API_DEV_KEY',
  'applicationKey' => 'YOUR_API_APP_KEY',
));
$session = $response->session;
$response = $client->ListProductOffers(array('session' => $session));
?>
<ul>
<?php foreach ($response->offers->Product as $product): ?>
  <li>
    <h2><?php print htmlspecialchars($product->Name); ?></h2>
    <img src="<?php print htmlspecialchars($product->ImagePath); ?>">
    <span><?php print htmlspecialchars($product->OfferPromotion); ?></span>
  </li>
<?php endforeach; ?>
</ul>
</body>
</html>

Which is roughly equivalent to the special offers listing on tesco.com.

There are some search methods as well, and a shopping basket; the best documentation of methods and parameter names is one of the XSD files.