iBlog random » amazon http://blog.zurka.us Just another WordPress weblog Tue, 28 May 2013 20:28:47 +0000 en-US hourly 1 http://wordpress.org/?v=3.6 Use PHP to Fetch an Album Artwork From Amazon http://blog.zurka.us/use-php-fetch-artwork-cd-from-amazon/ http://blog.zurka.us/use-php-fetch-artwork-cd-from-amazon/#comments Sun, 17 May 2009 22:59:16 +0000 nasal http://blog.zurka.us/?p=930

It’s actually pretty easy once you find out how to do it. By having the artist and album name you can fetch the album artwork from Amazon in three different sizes.

With php5 it’s very easy since it has an integrated xml parser. All we have to do is this:

$url = simplexml_load_file('http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=12DR2PGAQT303YTEWP02&Operation=ItemSearch&SearchIndex=Music&Artist=ARTIST&ResponseGroup=Images&Keywords=ALBUMNAME');

Please note that in the url I’ve put ARTIST and ALBUMNAME, which you should replace with what you’re searching for. Doing so, we get an xml file from which we can display the image like this:

echo '<img src="' . $url->Items->Item[0]->LargeImage->URL . '" />';

If we want the large one, that is. If we would like the medium one we would use MediumImage and SmallImage for the small one.

That’s it, it’s very useful if you are organizing your mp3 files or maybe building an online community or something.

Hope it helps somebody! If you find it useful, digg it!

ps: I forgot to mention that if you are using php4 this wont work, you will have to use another xml parser to fetch the image location from the xml provided by Amazon.

Have swing!

]]>
http://blog.zurka.us/use-php-fetch-artwork-cd-from-amazon/feed/ 5