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:
-
class AmazonController extends AppController{
-
-
function index() {
-
// Only needed if no Model has been loaded so far
-
App::import('ConnectionManager');
-
-
$amazon = ConnectionManager::getDataSource('amazon');
-
debug($response);
-
exit;
-
}
-
}
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
6 Comments
PHP4 Hater: I'm not impressed with the quality of their implementation and solving my own problem took me 30 minutes without getting me into a dependency with a library component that claims to be a framework and is 20 megs to download ... I'm happy : )
Hi there,
I have found a bug in this implementation, but i think it actually is a bug in cake's reverse function. More specifically, you invoke it at the end of your function as follows:
$r = Set::reverse(new Xml($r));
I have found out that when you do ItemLookup queries in amazon, although there are multiple Actor elements and multiple Format elements, the php array i end up is always populated with all values in the Actor and Format tags..On the other hand, i end up with a single Format element. If you want email me and i ll send you all the code so you can try it yourself..
thanks,
jason
cool, will look at it and improve. what about the bug? which features to implement would be most important?
cakemate: If you want to actively develop and maintain this let me know and I'll make sure to pull changes from you in GitHub.

interesting, as always. thanks for sharing, as always :)