3 # Copyright 2004-2005 Joshua Ferraro (jmf at kados dot org)
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
20 # This module dynamically pulls amazon content into Koha. It does not
21 # store the data in Koha's database. You'll need to get a developer's key
22 # as well as an associate's tag to use it.
23 # FIXME: need to write up more docs.
29 use vars qw($VERSION @ISA @EXPORT);
39 sub get_amazon_details {
43 # insert your dev key here
46 # insert your associates tag here
51 # old way from command line: shift @ARGV or die "Usage:perl amazon_http.ol <asin>\n";
53 #my $url = "http://xml.amazon.com/onca/xml3?t=" . $af_tag .
54 # "&dev-t=" . $dev_key .
55 # "&type=heavy&f=xml&" .
56 # "AsinSearch=" . $asin;
57 my $url = "http://xml.amazon.com/onca/xml3?t=$dev_key&dev-t=$af_tag&type=heavy&f=xml&AsinSearch=" . $asin;
59 #Here's an example asin for the book "Cryptonomicon"
64 my $content = get($url);
65 die "could not regrieve $url" unless $content;
67 my $xmlsimple = XML::Simple->new();
68 my $response = $xmlsimple->XMLin($content,
69 forcearray => [ qw(Details Product AvgCustomerRating CustomerReview) ],
72 #foreach my $result (@{$response->{Details}}){
73 # my $product_description = $result->{ProductDescription};
74 # my $image = $result->{ImageUrlMedium};
75 # my $price = $result->{ListPrice};
76 # my $reviews = $result->{