[Koha-cvs] koha/C4 Amazon.pm [rel_2_2]

Joshua Ferraro jmf at kados.org
Sat Feb 4 00:05:55 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch: 	rel_2_2
Changes by:	Joshua Ferraro <kados at savannah.gnu.org>	06/02/03 23:05:55

Added files:
	C4             : Amazon.pm 

Log message:
	Adds facility for Amazon.com Content for a Koha catalog

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/C4/Amazon.pm?only_with_tag=rel_2_2&rev=1.3.2.1

Patches:
Index: koha/C4/Amazon.pm
diff -u /dev/null koha/C4/Amazon.pm:1.3.2.1
--- /dev/null	Fri Feb  3 23:05:55 2006
+++ koha/C4/Amazon.pm	Fri Feb  3 23:05:55 2006
@@ -0,0 +1,77 @@
+package C4::Amazon;
+# Copyright 2006 LibLime
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+use XML::Simple;
+use LWP::Simple;
+use strict;
+require Exporter;
+
+use vars qw($VERSION @ISA @EXPORT);
+
+$VERSION = 0.02;
+=head1 NAME
+
+C4::Amazon - Functions for retrieving Amazon.com content in Koha
+
+=head1 FUNCTIONS
+
+This module provides facilities for retrieving Amazon.com content in Koha
+
+=cut
+
+ at ISA = qw(Exporter);
+
+ at EXPORT = qw(
+  &get_amazon_details
+);
+
+=head1 get_amazon_details($isbn);
+
+=head2 $isbn is a isbn string
+
+=cut
+
+sub get_amazon_details {
+	my ( $isbn ) = @_;
+
+	#get rid of MARC cataloger's nonsense
+	$isbn ~= /(p|-)//g;
+
+	# grab the developer's key: mine is 'ektostoukadou-20'
+	my $dev_key=C4::Context->preference('AmazonDevKey');
+
+	#grab the associates tag: mine is '0ZRY7YASKJS280T7YB02'
+	my $af_tag=C4::Context->preference('AmazonAssocTag');
+
+	my $asin=$isbn;
+	my $url = "http://xml.amazon.com/onca/xml3?t=$dev_key&dev-t=&type=heavy&f=xml&AsinSearch=" . $asin;
+	my $content = get($url);
+	warn "could not retrieve $url" unless $content;
+	my $xmlsimple = XML::Simple->new();
+	my $response = $xmlsimple->XMLin($content,
+  	forcearray => [ qw(Details Product AvgCustomerRating CustomerReview) ],
+);
+	return $response;
+}
+
+=head1 NOTES
+
+=head1 AUTHOR
+
+Joshua Ferraro <jmf at liblime.com>
+=cut





More information about the Koha-cvs mailing list