COM WEB SERVICES 680
_GetDataWithSoap() and _GetDataWithRest() return the list of products as an object. Then, we use the
_DataFormat() method to parse the data from this object and return that data in the form of an associative
array. The _DataFormat() method also places an ???image not available??? image for the Amazon.com products that
don??™t have a product image.
// Initializes Array object
$results = array ();
// Format results
$results = $this->_DataFormat($result);
// Returns results
return $results;
}
Let??™s look now at _GetDataWithRest() and _GetDataWithSoap(), which are the methods that do the actual
communication with AWS. _GetDataWithRest() retrieves web service data using REST. It starts by constructing
the required query string by joining the individual parameters you want to send to Amazon.com:
// Call AWS using REST
private function _GetDataWithRest()
{
$params = array ('Operation' => 'ItemSearch',
'SubscriptionId' => AMAZON_ACCESS_KEY_ID,
'Keywords' => AMAZON_SEARCH_KEYWORDS,
'SearchIndex' => AMAZON_SEARCH_NODE,
'ResponseGroup' => AMAZON_RESPONSE_GROUPS,
'Sort' => 'salesrank');
$query_string = '&';
foreach ($params as $key => $value)
$query_string .= $key . '=' . urlencode($value) . '&';
The complete Amazon.com URL that you need to call is composed of the base URL (which you saved as a constant
in include/config.
Pages:
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795