Hello
I signed up to use Amazons webservice tool, and have been
trying to write a load script to send a request useing soap and
take the results and push them to my DB. Only problem is
Amazons process only gives you 10 results, so you need to keep
sending requests with a new page id to get the next ten and the
next.
I have been trying to make a load script using the code from a
Devshed.com article as a base. The problem is when I try to make
a php while statement to auto retrieve each of the result pages,
my script keeps pulling only page 1. Please let me know if you
see anything wrong with my code. Any help would be greatly
appreciated
include("nusoap.php");
// create a instance of the SOAP client object
$soapclient = new
soapclient("http://soap.amazon.com/schemas2/AmazonWebServices.wsdl",true);
// uncomment the next line to see debug messages
// $soapclient->debug_flag = 1;
// create a proxy so that WSDL methods can be accessed directly
$proxy = $soapclient->getProxy();
// set up an array containing input parameters to be
$params = array(
'browse_node' => 18,
'page' => $page,
'mode' => 'books',
'tag' => 'bodyworksstud-20',
'type' => 'heavy',
'devtag' => 'DY7UAROU18HVG'
);
while ($total_pages >= $page)
{
$page = $page++;
$params['page'] = $page;
$result = $proxy->BrowseNodeSearchRequest($params);
if ($result['faultstring'])
{
echo $result['faultstring'];
}
else
{
$total = $result['TotalResults'];
$items = $result['Details'];
$total_pages = $total/10;
foreach ($items as $i)
{
// format and create product info from the results
$ProductName = $i['ProductName'];
$ProductName = str_replace("'","'", $ProductName);
$Asin = $i['Asin'];
$URL = $i['Url'];
$Catalog = $i['Catalog'];
$Manufacturer = $i['Manufacturer'];
$Media = $i['Media'];
$Availability = $i['Availability'];
$Authors = implode(", ", $i['Authors']);
$ImageUrlMedium = $i['ImageUrlMedium'];
$ListPrice = $i['ListPrice'];
$ListPrice = str_replace("$","", $ListPrice);
$OurPrice = $i['OurPrice'];
$OurPrice = str_replace("$","", $OurPrice);
$ThirdPartyNewPrice = $i['ThirdPartyNewPrice'];
$ThirdPartyNewPrice = str_replace("$","", $ThirdPartyNewPrice);
//Push content into DB
// print "<hr>$ProductName<br>\n$Asin<br>\n$URL<br>\n$ImageUrlMedium<br>\n$Manufacturer<br>\n$Authors<br>\n$Catalog<br>\n$Media<br>\n$Availability<br>\n$ListPrice<br>\n$OurPrice<br>\n$ThirdPartyNewPrice\n<br>\n";
$query = "INSERT INTO PE_Amazon_Book
( ProductName, Isbn, Url, ImageUrlMedium, Manufacturer, Authors, Catalog, Media, Availability, ListPrice, OurPrice, ThirdPartyNewPrice)
VALUES
('$ProductName','$Asin','$URL', '$ImageUrlMedium','$Manufacturer','$Authors', '$Catalog','$Media','$Availability', '$ListPrice', '$OurPrice', '$ThirdPartyNewPrice');";
$result = mysql_query($query);
$rows = mysql_affected_rows();
}
}
}