예제 #1
0
<p id="message" style="display:none"><img src="./meta/img/loading.gif" id="loading" /> Time to make the donuts...</p>
<script>
window.onload = function() {
var submit = document.getElementById('btn');
	submit.onclick = function() {
		var msg = document.getElementById("message");
		msg.style.display = 'block';
	}
}
</script>

<?php 
    $Amazon = new Amazon();
    $parameters = array("region" => "com", "AssociateTag" => "jasonclarkinf-20", "Operation" => "ItemSearch", "SearchIndex" => "Books", "ResponseGroup" => "Images,ItemAttributes,EditorialReview,Reviews,Similarities", "Keywords" => "{$q}");
    // this is what we are looking for, you could use the book's title instead
    $queryUrl = $Amazon->getSignedUrl($parameters);
    $request = simplexml_load_file($queryUrl) or die('API response not loading');
    if ($request->Items->TotalResults > 0) {
        // we have at least one response
        //set Amazon xml values as specifc variables to be printed out below
        $image = $request->Items->Item->SmallImage->URL;
        if (empty($image)) {
            $image = './meta/img/thumbnail-default.gif';
        }
        $title = $request->Items->Item->ItemAttributes->Title;
        $author = $request->Items->Item->ItemAttributes->Author;
        //simple logic check for author and director values
        if (strlen($author) > 2) {
            $creator = $author;
        } elseif (empty($author)) {
            $creator = $request->Items->Item->ItemAttributes->Director;