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.
25 # To use this module you need to do three things:
26 # 1. get a dev key and associate tag from Amazon
27 # 2. uncomment the Amazon stuff in opac-detail.pl
28 # 3. add the template variables to opac-detail.tmpl
29 # here's what's available:
34 # loop SimilarProducts (Product)
35 # loop Reviews (rating, Summary)
40 use vars qw($VERSION @ISA @EXPORT);
50 sub get_amazon_details {
54 # insert your dev key here
57 # insert your associates tag here
62 # old way from command line: shift @ARGV or die "Usage:perl amazon_http.ol <asin>\n";
64 #my $url = "http://xml.amazon.com/onca/xml3?t=" . $af_tag .
65 # "&dev-t=" . $dev_key .
66 # "&type=heavy&f=xml&" .
67 # "AsinSearch=" . $asin;
68 my $url = "http://xml.amazon.com/onca/xml3?t=$dev_key&dev-t=$af_tag&type=heavy&f=xml&AsinSearch=" . $asin;
70 #Here's an example asin for the book "Cryptonomicon"
75 my $content = get($url);
76 die "could not regrieve $url" unless $content;
78 my $xmlsimple = XML::Simple->new();
79 my $response = $xmlsimple->XMLin($content,
80 forcearray => [ qw(Details Product AvgCustomerRating CustomerReview) ],
83 #foreach my $result (@{$response->{Details}}){
84 # my $product_description = $result->{ProductDescription};
85 # my $image = $result->{ImageUrlMedium};
86 # my $price = $result->{ListPrice};
87 # my $reviews = $result->{