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â
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
$ git clone https://github.com/Exeu/Amazon-ECS-PHP-Library.git
Youâll only be using the file
lib/AmazonECS.class.php
so copy that wherever youâd likeOnce youâve got that file itâs easy-peasy-lemon-squeezy:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters<?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!'; }
Unfortunately itâs not working for me. Iâm always getting âNot found!â. Any clue what can be wrong?
I did forget to mention that in order to get an affiliate ID you need to become an associate. To become an associate, follow instructions here: http:/ /docs.aws.amazon.com/AWSâŠ.
If you have all your credentials correct, and your include path is correct, then this works. I just tested it today.