sync with dev_week.
This commit is contained in:
parent
e624b89b56
commit
32e0d66afa
51
C4/Amazon.pm
51
C4/Amazon.pm
|
|
@ -34,12 +34,23 @@ package C4::Amazon;
|
|||
# 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 @@ $VERSION = 0.01;
|
|||
&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 @@ my $asin=$isbn;
|
|||
# "&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 <jmf@liblime.com>
|
||||
=cut
|
||||
|
|
|
|||
4563
C4/Biblio.pm
4563
C4/Biblio.pm
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue