removing website management, that is now useless
[koha.git] / C4 / Amazon.pm
1
2 package C4::Amazon;
3 # Copyright 2004-2005 Joshua Ferraro (jmf at kados dot org)
4 #
5 # This file is part of Koha.
6 #
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
10 # version.
11 #
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.
15 #
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
19 #
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.
24 #
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: 
30 #    ProductDescription
31 #    ImageUrlMedium
32 #    ListPrice
33 #    url
34 #    loop SimilarProducts (Product)
35 #    loop Reviews (rating, Summary)
36 #
37 use strict;
38 require Exporter;
39
40 use vars qw($VERSION @ISA @EXPORT);
41
42 $VERSION = 0.01;
43
44 @ISA = qw(Exporter);
45
46 @EXPORT = qw(
47   &get_amazon_details
48 );
49
50 sub get_amazon_details {
51
52 my ( $isbn ) = @_;
53
54 # insert your dev key here
55 my $dev_key='';
56
57 # insert your associates tag here
58 my $af_tag='';
59
60 my $asin=$isbn;
61
62 # old way from command line: shift @ARGV or die "Usage:perl amazon_http.ol <asin>\n";
63
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;
69
70 #Here's an example asin for the book "Cryptonomicon"
71 #0596005423";
72
73 # use XML::Simple;
74 # use LWP::Simple;
75 my $content = get($url);
76 die "could not regrieve $url" unless $content;
77
78 my $xmlsimple = XML::Simple->new();
79 my $response = $xmlsimple->XMLin($content,
80   forcearray => [ qw(Details Product AvgCustomerRating CustomerReview) ],
81 );
82 return $response;
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->{
88 #       return $result;
89 #}
90 }