Ejecutando una búsqueda
1 : <?php
2 : define('AWS_ID', 'ABCFOOBARXYZ13579');
3 :
4 : $keywords = 'PHP';
5 : $aws_call = 'http://webservices.amazon.com/onca/xml'
6 : .'?Service=AWSECommerceService'
7 : .'&SubscriptionId='.AWS_ID.'&Operation=ItemSearch'
8 : .'&Keywords='.$keywords.'&SearchIndex=Books&Sort=salesrank';
9 : $results = file_get_contents($aws_call);
10 :
11 : $xml = simplexml_load_string($results);
12 : $re = '/[\n ]+/';
13 : foreach ($xml->Items->Item as $item) {
14 : $title = trim(preg_replace($re,' ', $item->ItemAttributes->Title));
15 : $author = $item->ItemAttributes->Author;
16 : $asin = $item->ASIN;
17 : echo "* '$title',\n $author (ASIN: $asin)\n";
18 : }
19 : ?>
Resultado
* 'Beginning PHP 5 and MySQL: From Novice to Professional', W. J. Gilmore (ASIN: 1893115518) * 'PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide', Larry Ullman (ASIN: 0321186486) * 'PHP and MySQL Web Development (3rd Edition) (Developer's Library)', Luke Welling (ASIN: 0672326728) * 'Php Web Development With Macromedia Dreamweaver Mx 2004', Rachel Andrew (ASIN: 1590593502) * 'Web Database Applications with PHP & MySQL, 2nd Edition', Hugh E. Williams (ASIN: 0596005431) * 'Learning PHP 5', David Sklar (ASIN: 0596005601) * 'Setting Up LAMP: Getting Linux, Apache, MySQL, and PHP Working Together', Eric Rosebrock (ASIN: 0782143377) * 'PHP Cookbook', David Sklar (ASIN: 1565926811) * 'Build Your Own Database Driven Website Using PHP and MySQL, 3rd Edition', Kevin Yank (ASIN: 0975240218) * 'Php 5 Objects, Patterns, Practice', Matt Zandstra (ASIN: 1590593804)