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

Issue Type: Bug Created: 2011-11-21T22:12:23.000+0000 Last Updated: 2012-04-09T04:01:08.000+0000 Status: Open Fix version(s): Reporter: Mixu Kastelen (yellowhat) Assignee: Enrico Zimuel (zimuel) Tags: - Zend_Service_Amazon

Related issues: Attachments:


Amazon requires an associate tag for all API queries now, see…:

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… 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');


Posted by Alex (2ndak) on 2012-03-25T17:34:53.000+0000

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.

Posted by Justin Silver (jsilver) on 2012-04-09T04:01:08.000+0000

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', '…'); with : $xpath->registerNamespace('az', '…');

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!

Have you found an issue?

See the Overview section for more details.


© 2006-2019 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.