Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <HTML>
- <head>
- <title>Amazon search test</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <style type="text/css">
- UNKNOWN {
- FONT-SIZE: small; COLOR: #000000; FONT-FAMILY: verdana, sans-serif
- }
- BODY {
- FONT-SIZE: small; FONT-FAMILY: verdana, sans-serif
- }
- pre {background:#eeeeee;border:1px solid #777777;padding:4px}
- </style>
- </head>
- <BODY BGCOLOR=#FFFFFF >
- <!-- search form -->
- <form name="htmlform" method="post" action="test.php">
- title search: <input type="text" name="title" maxlength="50" size="30">
- <input type="submit" value="Submit">
- </form>
- <!-- query Amazon and show result -->
- <?php
- // associations between a label and its organization
- $labels = array(
- 'MGM' => 'RIAA',
- 'Universal Music' => 'GEMA'
- );
- // test, if there was a search word submitted
- if(isset($_POST['title'])) {
- // query Amazon
- include("amazon_api_class.php");
- $obj = new AmazonProductAPI();
- try {
- $result = $obj->searchProducts($_POST['title'], AmazonProductAPI::DVD, "TITLE");
- } catch(Exception $e) {
- echo $e->getMessage();
- }
- /*
- // debug ouput of the result XML
- echo "<pre>"
- print_r($result);
- echo "</pre>"
- echo "<hr>"
- */
- // show result
- echo "<hr>";
- foreach ($result->Items->Item as $item) {
- echo "Title : {$item->ItemAttributes->Title}<br>";
- echo "ASIN : {$item->ASIN}<br>";
- $label = $item->ItemAttributes->Label;
- echo "Label : {$label}<br>";
- // search for the label: test all entries in the labels array,
- // if the label is part of the returned label, ignore lower/uppercase
- $org = "unknown";
- foreach ($labels as $labelTest => $organization) {
- if (strpos(strtolower($label), strtolower($labelTest)) !== false) {
- $org = $organization;
- break;
- }
- }
- // show result
- echo "Organization: $org<br>";
- // show image
- echo "<img src=\"" . $item->MediumImage->URL . "\" /><br>";
- echo "<hr>";
- }
- }
- ?>
- <HR>
- <p><a href="mailto:fb@frank-buss.de"><img src="../img/email.gif" width="64" height="64" align="left" border="0"></a>
- <address>
- 22. März 2012, <a href="mailto:fb@frank-buss.de">Frank Buß</a>
- </address>
- </body>
- </html>
Add Comment
Please, Sign In to add comment