Amazon Associates API (data source) for CakePHP

Posted by Felix Geisendörfer, on Jul 31, 2008 - in PHP & CakePHP » DataSources, Models & Behaviors

Hey folks,

just wanted to let you know about a new addition to the debuggable scraps repository: An API for the Amazon Associates Web Service. Right now it's really just a simple wrapper to allow you to search their catalog since that was all I needed for now. But thanks to the almighty fork button on github you can easily change that ; ).

Using the API is as simple as:

php
  1. class AmazonController extends AppController{
  2.   var $uses = array();
  3.  
  4.   function index() {
  5.     // Only needed if no Model has been loaded so far
  6.     App::import('ConnectionManager');
  7.  
  8.     $amazon = ConnectionManager::getDataSource('amazon');
  9.     $response = $amazon->find('DVD', array('title' => 'The Devil and Daniel Johnston'));
  10.     debug($response);
  11.     exit;
  12.   }
  13. }

Documentation and code can be found here: Download the Amazon Associates API for CakePHP.

Hint: If you are looking for DVD covers you'll have to pass 'info' => 'Images' as a second query option.

Alright, hope that's useful to some of you out there : ),

-- Felix Geisendörfer aka the_undefined