You are here

function _amazon_item_batch_lookup_from_web in Amazon Product Advertisement API 7.2

Same name and namespace in other branches
  1. 6 amazon.module \_amazon_item_batch_lookup_from_web()
  2. 7 amazon.module \_amazon_item_batch_lookup_from_web()

Get 10 or less items from the AWS web service. AWS allows ONLY 10 items, See http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.ht....

Parameters

$item_ids: Array of ASINs to be looked up.

Return value

Array of ASIN data structures keyed by ASIN.

1 call to _amazon_item_batch_lookup_from_web()
amazon_item_lookup_from_web in ./amazon.module
Use Amazon API to look up an array of ASINs.

File

./amazon.module, line 505

Code

function _amazon_item_batch_lookup_from_web($item_ids = array(), $locale = NULL) {
  if (!empty($item_ids)) {
    $params = array(
      'ItemId' => implode(',', $item_ids),
      'ResponseGroup' => amazon_get_response_groups(),
    );
    $results = amazon_http_request('ItemLookup', $params, $locale);
    if (!empty($results->Items->Request->Errors)) {
      _amazon_item_batch_lookup_from_web_errors($results->Items->Request->Errors);
    }
    $items = array();
    if (!empty($results->Items->Item)) {
      foreach ($results->Items->Item as $xml) {
        $item = amazon_item_clean_xml($xml);
        amazon_item_insert($item);
        $items["{$item['asin']}"] = $item;
      }
    }
    return $items;
  }
  return array();
}