Prev | Current Page 782 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

COM WEB SERVICES 679
if (property_exists($temp, 'VariationSummary') &&
property_exists($temp->VariationSummary, 'LowestPrice'))
{
$new_result[$k]['price'] =
(string) $temp->VariationSummary->LowestPrice->FormattedPrice;
$highest_price = $new_result[$k]['price'];
if (property_exists($temp->VariationSummary, 'HighestPrice'))
$highest_price =
(string) $temp->VariationSummary->HighestPrice->FormattedPrice;
if ($highest_price !== $new_result[$k]['price'])
$new_result[$k]['price'] .= ' - ' . $highest_price;
}
else
$new_result[$k]['price'] = '';
$k++;
}
return $new_result;
}
}
?>
How It Works: Communicating with AWS
The only public Amazon.com business-tier method is GetProducts() that takes care to retrieve data. Its functionality
is quite clear, because it uses a number of helper methods to get the work done. First, it decides whether
it should use SOAP or REST depending on the configuration setting you added to include/config.php:
define('AMAZON_METHOD', 'SOAP');
The AMAZON_METHOD constant you defined in include/config.php instructs whether AWS will be contacted
through REST or SOAP. The value of that constant (which should be REST or SOAP) decides whether
_GetDataWithRest() or _GetDataWithSoap() will be used to contact Amazon. No matter which method
you choose, the results should be the same:
// Retrieves Amazon products for sending to presentation tier
public function GetProducts()
{
// Use SOAP to get data
if (AMAZON_METHOD == 'SOAP')
$result = $this->_GetDataWithSoap();
// Use REST to get data
else
$result = $this->_GetDataWithRest();
CHAPTER 22 ?–  USING AMAZON.


Pages:
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794
teksty piosenek noclegi swinoujscie poker online Betsson Poker stretching exercises grow taller