talResults'] ;
unset($soapclient);
unset($soap_proxy);
}
else
{
$this->type = 'search';
$this->search=$search;
$this->page = $page;
$search = urlencode($search);
$this->mode = $mode;
$this->url = 'http://xml.amazon.com/onca/xml2?t='.ASSOCIATEID
.'&dev-t='.DEVTAG.'&KeywordSearch='
.$search.'&mode='.$this->mode
.'&type=heavy&page='
.$this->page
.'&sort=+salesrank&f=
xml';
$this->parseXML();
}
return $this->products;
}
// Parse the XML into Product object(s)
function parseXML()
{
// suppress errors because this will fail sometimes
$xml = @simplexml_load_file($this->url);
if(!$xml)
{
//try a second time in case just server busy
$xml = @simplexml_load_file($this->url);
if(!$xml)
{
return false;
}
}
$this->totalResults = (integer)$xml->TotalResults;
foreach($xml->Details as $productXML)
{
$this->products[] = new Product($productXML);
}
}
}
?>