At Custom Channels we have our own API for Album Art. Our Album Art API was designed before I got here, it was designed for the single use-case of the Custom Channels standard flash player (i.e. 125×125 gif) and isn’t what you’d call “future proof”.

ANYWAY, we’re revisiting some of the Custom Channels’ site design and one idea I had is to show a handful of recently played albums from a few channels on our homepage. And a 125×125 gif ain’t gonna to cut the mustard!

This brings us to the topic of this post—the Amazon Product Advertising API—Step-by-Step.

This assumes you’ve already got a development environment that runs PHP5.

  • The first thing to do, if you haven’t already, is to register for Amazon Web Services
  • After you’ve registered for a AWS account, login to your account and go to the “My Account/Console” pulldown at the top and click, “Security Credentials”
  • Scroll down to “Access Credentials”
    Access Credentials
  • Copy your “Access Key ID”, click “Show” and copy your “Secret Access Key”
  • Go ahead and clone the Amazon ECS PHP Library to your development environment

  • You’ll only be using the file lib/AmazonECS.class.php so copy that wherever you’d like
  • Once you’ve got that file it’s easy-peasy-lemon-squeezy:

    <?php
    require_once 'lib/AmazonECS.class.php';
    $track = $_GET['track'];
    $access_key_id = 'YOUR ACCESS KEY ID';
    $secret_access_key = 'YOUR SECRET ACCESS KEY';
    $affiliate_id = 'YOUR AFFILIATE ID';
    $client = new AmazonECS($access_key_id, $secret_access_key, 'com', $affiliate_id);
    $response = $client->category('DigitalMusic')->responseGroup('Images')->search($track);
    if (getType($response->Items->Item) == 'object') {
    echo '<img src="' . htmlspecialchars($response->Items->Item->LargeImage->URL) . '">';
    } elseif (getType($response->Items->Item) == 'array') {
    echo '<img src="' . htmlspecialchars($response->Items->Item[0]->LargeImage->URL) . '">';
    } else {
    echo 'Not Found!';
    }
    The code above will take the argument from the “track” url parameter and search Amazon’s digital music store and output the large-format album art for the top match.