I'm playing around with the Amazon developer's API and I'm not getting anything.
Here is my code. I am using echo
to see if anything is happening and all I am getting is a blank webpage. I expected the array of search results to be echoed.
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once('Zend/Service/Amazon.php');
$amazon = new Zend_Service_Amazon('AKIAJQBYUXIFWUIX6W6A', 'US', 'YGV9zePfKejV6C3dpaP/NtnhjGLfWQsccdGSSL50');
$results = $amazon->itemSearch(array('SearchIndex' => 'Books',
'Keywords' => 'php'));
foreach ($results as $result) {
echo $result->Title . '<br />';
}
?>
getting a blank page still
Your page is blank because you are no getting any results:
This is the $results dump using your published code:
Amazon object(Zend_Service_Amazon_ResultSet)#103 (4) {
["_results":protected] => object(DOMNodeList)#105 (0) {
}
["_dom":protected] => object(DOMDocument)#101 (0) {
}
["_xpath":protected] => object(DOMXPath)#104 (0) {
}
["_currentIndex":protected] => int(0)
}
There are several issues to resolve to make this work, the biggest one being this:
The following changes will take effect on 11/1/2011:
Associate Tag Parameter: Every request made to the API should include a valid Associate Tag. Any request that does not contain a valid Associate Tag will be rejected with an appropriate error message. For details on the Associate Tag parameter, please refer to our Developer guide.
Currently the constructor for Zend_Service_Amazon
does not include the Associate Tag parameter and the _prepareOptions()
method does not set the option.
I'm sure someone has a fix for this, otherwise it's time to dig in and extend... Good Luck
Amazon Product Advertising API
Changes to Product Advertising API