|
||||
|
Seems there is a lack of documentation related to working with Zend_Service_Amazon, so newbies can easily get lost...
For getting detailed information about an item (as images, reviews, aso) would be needed to use ResponseGroup clause. Here are two samples, first using Traditional API, Second is by using Query API: require_once 'Zend/Service/Amazon.php'; $amazon = new Zend_Service_Amazon((string)$this->config->site->api_key); $this->view->books = $amazon->itemSearch(array('SearchIndex' => 'Books', 'Keywords' => 'PHP', 'ResponseGroup'=>'Large' )); require_once 'Zend/Service/Amazon/Query.php'; $query = new Zend_Service_Amazon_Query((string)$this->config->site->api_key); $query->category('Books')->Keywords('PHP')->ResponseGroup('Large'); $this->view->books = $query->search();
__________________
Zend Framework Tutorials | Zend Framework Forums | Zend Framework IRC Channel | | Zend Framework Resources | CoreShifter | Microsoft Forums | Microsoft Links | Microsoft Books |
|
|||
|
This does help, but I'm still having a problem with this service. Specifically, my foreach loop produces ten results, but I can't seem to get anything to actually show up. I.e., my tags are all empty.
Here's what I've got so far: Code:
class Amazon
{
function getAmazon($keywords)
{
$amazon = new Zend_Service_Amazon_Query('APIKEYGOESHERE','US');
$amazon->category('Books')
->Keywords($keywords)
->ResponseGroup('Small,Images');
$results = $amazon->search();
if ($results->totalResults() > 0)
{
return $results;
}
else
{
return NULL;
}
}
}
Code:
$amazon = new Amazon; $aresults = $amazon->getAmazon($tag1); $this->view->amazon = $aresults; Code:
<?php foreach($this->amazon as $key => $amazon) : ?> <div><a href = "<?php $amazon->DetailPageURL; ?>"><img src = "<?php $amazon->SmallImage->Url; ?>" /></a></div> <?php endforeach; ?> Edit: I'm an idiot. I just forgot the friggin' echo. I must have stared at this for an hour without seeing that. Last edited by atrus123 : 08-03-2008 at 12:11 AM. Reason: I'm an idiot... |
![]() |
| Thread Tools | |
| Display Modes | |
|
|