Getting results from Amazon API onto my webpage

I’m currently in the process of creating a search page which will be using the Amazon catalog for results. All I want to do is search for a title at Amazon and bring back the results onto my webpage. I’ve signed up to the Product Advertising API and have read the documents they supply but it just doesn’t explain a simply, easy to understand way to do it. Does anyone has a tutorial or guide as to how to do this? There are quite a few tutorials on the web but these are either outdated or do not explain what it does. I want to understand what it is the code does rather than just copy and paste it into my website.

Thanks in advance

I take it nobody has tried to do this. Thanks anyways

Hi freakystreak,

Don’t give up so fast :wink: I’ve used the Amazon product API before to grab images and pricing information, so I might be able to help. What exactly do you want to do? Is the title that you want to search for is only in a specific category (e.g. DVDs)? And what kind of results do you want to display on your site?

Thanks for the reply, I want to search for games, dvds, blurays and music using a search form on my website. I just need to callback the title, artist or director/star and what it is (game, dvd, music cd). The documentation seems very confusing. I just need some example code to get me on the right path or a nudge in the right direction. If you can help in any way it will be greatly appreciated.

Here’s some code that should get you started. It uses a PHP library called APaPi. Note that I haven’t used this code in a while, so it’s quite possible Amazon have changed the API since.


require_once( dirname(__FILE__) . '/Amazon/AmazonProductAPI.php' );
spl_autoload_register(array('AmazonProductAPI', 'autoload') );

$api = new AmazonProductAPI();
$api->setAccessKey( 'yourAccessKey' );
$api->setSecretKey( 'yourSecretKey' );
$api->setAssociateId( 'yourAssociateId' );
$api->setLocale( "UK" ); // Set to the Amazon locale you want to search

$request = new AmazonProduct_Request();
$request->Operation = AmazonProduct_Operation::ITEM_SEARCH;
// AmazonProduct_SearchIndex::SupportedSearchIndexes() will give you a list of the supported indexes
$request->SearchIndex = AmazonProduct_SearchIndex::VIDEO_GAMES;
// You may need to change the response group to get the info you need (eg. artist or director)
$request->ResponseGroup = AmazonProduct_ResponseGroup::SMALL;

// Search by keywords
$request->Keywords = $terms;
// or title
$request->Title = $terms;


// Send Request
$response = $this->_api->execute( $request );

// verify and use the response
if( $response->isSuccess() && $response->TotalResults > 0 )
{
    // Do something with $response->Items
}

Thanks very much for the heads up. Will take a look this week. Really appreciate it.