Issues

ZF-11904: Amazon requires AssociateTag for all API queries since 2011-11-01

Description

Amazon requires an associate tag for all API queries now, see https://affiliate-program.amazon.com/gp/…:


The changes, described below, will help us continue to provide you with relevant and useful features to advertise Amazon products. The following changes to the API will take effect on November 1, 2011:

  • Associate Tag will be a required and verified input parameter in all requests to the API

The sample code at http://framework.zend.com/manual/en/… does not work any more:


$query = new Zend_Service_Amazon_Query('AMAZON_API_KEY', 'US', 'AMAZON_SECRET_KEY'); $query->category('Books')->Keywords('PHP'); $results = $query->search(); foreach ($results as $result) { echo $result->Title . '
'; }


A first step would be to update the documentation to reflect this working usage:

$query ->category('Books') ->AssociateTag('myassociatetag-21') ->Keywords('PHP');

But preferably the constructor would be changed:

$query = new Zend_Service_Amazon_Query('AMAZON_API_KEY', 'US', 'AMAZON_SECRET_KEY', 'myassociatetag-21');

Comments

I am running into this problem with API itemSearch(). There is no way (or i am not aware of) to insert the AssociateTag to the request.

I am surprise to see no more people are affected by this. Maybe there isn't that many people using the Zend_Service_Amazon APIs.

I updated my local code to support the Amazon changes. One required change for me was the xpath namespace - all of the instances of "2005-10-05" in the Zend/Service/Amazon/*.php will need to be updated to replace: $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/…'); with : $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/…');

To modify the constructor as in the example above "$query = new Zend_Service_Amazon_Query('AMAZON_API_KEY', 'US', 'AMAZON_SECRET_KEY', 'myassociatetag-21')" you will need to update Zend/Service/Amazon.php

// Zend/Service/Amazon.php - add property

/**
 * @var string
 */
protected $_associateTag = null;

// Zend/Service/Amazon.php - update constructor

public function __construct($appId, $countryCode = 'US', $secretKey = null, $associateTag=null)
{
    // ...
    $this->_associateTag = $associateTag;
    // ...
}

// Zend/Service/Amazon.php - update _prepareOptions()

 protected function _prepareOptions($query, array $options, array $defaultOptions)
{
    // ...
    $options['AssociateTag']   = $this->_associateTag;
    // ...
}

Good luck!