Can anyone see why this code will not work?
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use strict;
print "Content-type: text/html \n\n";
# define variables...
my ($assoc_id,$search,$mode);
$search = "wild";
$assoc_id = "bn23-21";
$mode = "all";
my $image_size = "small";
my $bgcolor = "FFFFFF";
my $bgshade = "F0F8FF";
my $amazon_results = &get_amazon_results($assoc_id,$search,$mode);
foreach my $product (@{$amazon_results->{product}})
{
my $image = $product->{image}[0] if !ref $product->{image}[0];;
my $small_image = $product->{small_image}[0] if !ref $product->{small_image}[0];
$image = $small_image if $image_size eq "small";
print "<tr valign=top bgcolor=\#$bgcolor>";
print "<td>", img {src=>$image,align=>'LEFT',alt=>$product->{title}[0]}, "</td>";
print "<td align=left>", a({href=>$product->{tagged_url}[0]}, $product->{title}[0]), br;
print "<i>By: ", $product->{author}[0], "</i>, ", $product->{binding}[0], " edition", br;
print "List Price: ", $product->{list_price}[0], ";" if !ref $product->{list_price}[0];
print " Our Price: ", $product->{our_price}[0] if !ref $product->{our_price}[0];
print "</td>";
print "</tr>\n";
print "<tr><td colspan=2>\ </td></tr>";
if ($bgcolor eq "FFFFFF") {
$bgcolor = $bgshade;
}
else {
$bgcolor = "FFFFFF";
}
}
sub get_amazon_results() {
my ($t,$search,$mode) = @_;
use LWP;
use HTTP::Request;
use XML::Simple;
use Data::Dumper;
my $url="http://rcm.amazon.com/e/cm?t=$t&l=st1&search=$search&mode=$mode&p=102&o=1&f=xml";
my $method="GET";
my $ua = new LWP::UserAgent;
$ua->agent("Mozilla/4.04 (X11; I; NetBSD 1.3 i386; Nav)");
$ua->timeout("30");
my $request = new HTTP::Request($method, $url);
my $response = $ua->request($request);
my $return = $response->content;
my $doc=XMLin($return, forcearray=>1);
return $doc;
}
No error is returned...it simply just returns a blank page. I've checked into the URL that is called, and that seems to be o. I'm just totally stumped
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Code:
#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use strict;
print "Content-type: text/html \n\n";
# define variables...
my ($assoc_id,$search,$mode);
$search = "wild";
$assoc_id = "bn23-21";
$mode = "all";
my $image_size = "small";
my $bgcolor = "FFFFFF";
my $bgshade = "F0F8FF";
my $amazon_results = &get_amazon_results($assoc_id,$search,$mode);
foreach my $product (@{$amazon_results->{product}})
{
my $image = $product->{image}[0] if !ref $product->{image}[0];;
my $small_image = $product->{small_image}[0] if !ref $product->{small_image}[0];
$image = $small_image if $image_size eq "small";
print "<tr valign=top bgcolor=\#$bgcolor>";
print "<td>", img {src=>$image,align=>'LEFT',alt=>$product->{title}[0]}, "</td>";
print "<td align=left>", a({href=>$product->{tagged_url}[0]}, $product->{title}[0]), br;
print "<i>By: ", $product->{author}[0], "</i>, ", $product->{binding}[0], " edition", br;
print "List Price: ", $product->{list_price}[0], ";" if !ref $product->{list_price}[0];
print " Our Price: ", $product->{our_price}[0] if !ref $product->{our_price}[0];
print "</td>";
print "</tr>\n";
print "<tr><td colspan=2>\ </td></tr>";
if ($bgcolor eq "FFFFFF") {
$bgcolor = $bgshade;
}
else {
$bgcolor = "FFFFFF";
}
}
sub get_amazon_results() {
my ($t,$search,$mode) = @_;
use LWP;
use HTTP::Request;
use XML::Simple;
use Data::Dumper;
my $url="http://rcm.amazon.com/e/cm?t=$t&l=st1&search=$search&mode=$mode&p=102&o=1&f=xml";
my $method="GET";
my $ua = new LWP::UserAgent;
$ua->agent("Mozilla/4.04 (X11; I; NetBSD 1.3 i386; Nav)");
$ua->timeout("30");
my $request = new HTTP::Request($method, $url);
my $response = $ua->request($request);
my $return = $response->content;
my $doc=XMLin($return, forcearray=>1);
return $doc;
}
No error is returned...it simply just returns a blank page. I've checked into the URL that is called, and that seems to be o. I'm just totally stumped
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!