Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-14-2007, 02:07 PM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 99
Default Working with Zend_Service_Amazon

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();
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-31-2008, 02:10 AM
Junior Member
 
Join Date: Jul 2008
Posts: 7
Default

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; ?>
Any guidance would be appreciated.

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...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 06:35 AM.