[Web4lib] Amazon image function
Andrew Nagy
andrew.nagy at villanova.edu
Wed Jan 30 11:48:38 EST 2008
Glen - My solution might not be any better than what has been posted already or what you have done - but feel free to steal the code from VuFind (It's in PHP). We use Amazon Book Covers and soon to offer Syndetics Book Covers as well. The code works quite well with very few errors - from what I have seen anyway.
The file that you'd be looking for is in the code repository:
http://vufind.svn.sourceforge.net/viewvc/vufind/trunk/web/bookcover.php?revision=259&view=markup
It uses some PEAR libraries, so there are a few dependencies.
Join the code4lib list - I think you will find that list to be much more technical.
Andrew
> -----Original Message-----
> From: web4lib-bounces at webjunction.org [mailto:web4lib-
> bounces at webjunction.org] On Behalf Of Glen Wiley
> Sent: Tuesday, January 29, 2008 4:39 PM
> To: web4lib at webjunction.org
> Subject: [Web4lib] Amazon image function
>
> Hi everyone,
>
> I know people have discussed Amazon book images issues on this listserv
> before, but here is a more technical question.
>
> I'm using this php code to pull Amazon book cover images into a new
> book
> list. It does work, but I wondered if anyone had a suggestion about
> how
> to do it better. We aren't getting very many successful image displays
> because many of them time out or error out. So out of 100 new books, I
> get 10 images appear. Any suggestions here?
>
> function RESTQuery($isbn){
> //1VE157GS2Z7SMVS61G02
> $base = 'http://ecs.amazonaws.com/onca/xml';
> $query_string = '';
>
> $params = array(
> 'ItemId' => "$isbn",
> 'IdType' => "ASIN",
> 'Service' => 'AWSECommerceService',
> 'Operation' => 'ItemLookup',
> #'SearchIndex' => 'Books',
> #'sort' => '+relevance',
> 'ResponseGroup' => 'Images',
> 'AWSAccessKeyId' => '1VE157GS2Z7SMVS61G02',
> 'Style' => "XML",
> 'XMLEscaping' => "Double",
> 'Version' => "2007-07-16"
> );
>
> foreach ($params as $key => $value) {
> $query_string .= "$key=" . urlencode($value) . "&";
> }
>
> $url = "$base?$query_string";
>
> $xmlstr = file_get_contents($url);
> if($xmlstr == "") return;
> $xml = new SimpleXMLElement($xmlstr);
> #return $xml->asXml();
> $imageURL = $xml->Items->Item->MediumImage->URL;
>
> if($imageURL != ""){
> return "<a href=\"http://www.amazon.com\"><img src=\"$imageURL\"
> /></a>";
> }
> else{
> return "";
> }
> }
>
>
> --Glen
>
>
>
> -----------------------------------------------------------------------
> -
>
> Glen Wiley
> Metadata Librarian
>
> Metadata Services <http://metadata.library.cornell.edu/>
>
> 107E Olin Library
> Cornell University
> Ithaca, NY 14853/
> /gsw55 at cornell.edu <mailto:gsw55 at cornell.edu>
> 607-254-5145
>
>
> --/ Our Vision is to be internationally recognized and respected as a
> center of metadata expertise. --/
>
>
>
> _______________________________________________
> Web4lib mailing list
> Web4lib at webjunction.org
> http://lists.webjunction.org/web4lib/
More information about the Web4lib
mailing list