koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/C4 Amazon.pm


From: Antoine Farnault
Subject: [Koha-cvs] koha/C4 Amazon.pm
Date: Thu, 10 Aug 2006 12:41:04 +0000

CVSROOT:        /sources/koha
Module name:    koha
Changes by:     Antoine Farnault <toins>        06/08/10 12:41:04

Modified files:
        C4             : Amazon.pm 

Log message:
        sync with dev_week.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Amazon.pm?cvsroot=koha&r1=1.3&r2=1.4

Patches:
Index: Amazon.pm
===================================================================
RCS file: /sources/koha/koha/C4/Amazon.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- Amazon.pm   26 Oct 2005 09:12:33 -0000      1.3
+++ Amazon.pm   10 Aug 2006 12:41:04 -0000      1.4
@@ -34,12 +34,23 @@
 #    loop SimilarProducts (Product)
 #    loop Reviews (rating, Summary)
 #
+use XML::Simple;
+use LWP::Simple;
 use strict;
 require Exporter;
 
 use vars qw($VERSION @ISA @EXPORT);
 
-$VERSION = 0.01;
+$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
 
 @ISA = qw(Exporter);
 
@@ -47,15 +58,24 @@
   &get_amazon_details
 );
 
+=head1 get_amazon_details($isbn);
+
+=head2 $isbn is a isbn string
+
+=cut
+
 sub get_amazon_details {
 
 my ( $isbn ) = @_;
 
 # insert your dev key here
-my $dev_key='';
+       $isbn =~ s/(p|-)//g;
 
 # insert your associates tag here
-my $af_tag='';
+       my $dev_key=C4::Context->preference('AmazonDevKey');
+
+       #grab the associates tag: mine is '0ZRY7YASKJS280T7YB02'
+       my $af_tag=C4::Context->preference('AmazonAssocTag');
 
 my $asin=$isbn;
 
@@ -65,26 +85,19 @@
 #      "&dev-t=" . $dev_key .
 #      "&type=heavy&f=xml&" .
 #      "AsinSearch=" . $asin;
-my $url = 
"http://xml.amazon.com/onca/xml3?t=$dev_key&dev-t=$af_tag&type=heavy&f=xml&AsinSearch=";
 . $asin;
-
-#Here's an example asin for the book "Cryptonomicon"
-#0596005423";
-
-# use XML::Simple;
-# use LWP::Simple;
+       my $url = 
"http://xml.amazon.com/onca/xml3?t=$af_tag&dev-t=$dev_key&type=heavy&f=xml&AsinSearch=";
 . $asin;
 my $content = get($url);
-die "could not regrieve $url" unless $content;
-
+       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;
-#foreach my $result (@{$response->{Details}}){
-#      my $product_description = $result->{ProductDescription};
-#      my $image = $result->{ImageUrlMedium};
-#      my $price = $result->{ListPrice};
-#      my $reviews = $result->{
-#      return $result;
-#}
 }
+
+=head1 NOTES
+
+=head1 AUTHOR
+
+Joshua Ferraro <address@hidden>
+=cut




reply via email to

[Prev in Thread] Current Thread [Next in Thread]