Last active
June 20, 2017 16:15
-
-
Save Exeu/4674423 to your computer and use it in GitHub Desktop.
Amazon ECS Sample Page: http://amazonecs.pixel-web.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var globalRequest = 0; | |
$('#search').bind('keyup', function(event) { | |
if (event.keyCode == 13) { | |
searchAction(); | |
} | |
}); | |
$('#search-link').bind('click', function(event) { | |
searchAction(); | |
}); | |
var searchAction = function() { | |
var value = $('#search').val(); | |
var cat = $('#category').val(); | |
var country = $('#country').val(); | |
var page = $('#page').val(); | |
var track = value + " - " + cat + " - " + country; | |
var resultContainer = $('#results'); | |
if (value.length < 3 && globalRequest == 1) { | |
return; | |
} | |
//_gaq.push(['_trackEvent', 'Search', track]); | |
globalRequest = 1; | |
$.ajax({ | |
url: "search.php", | |
dataType: 'json', | |
type: 'GET', | |
data: "q="+value+"&category="+cat+"&country="+country+"&page="+page, | |
success: function(data){ | |
globalRequest = 0; | |
resultContainer.fadeOut('fast', function() { | |
resultContainer.html(''); | |
for (var x in data) { | |
if (!data[x].price) | |
data[x].price = 'kA'; | |
if (!data[x].img) | |
data[x].img = 'assets/images/no.gif'; | |
var html = '<div class="res-container">'; | |
html += '<h2><a href="'+data[x].url+'" target="_blank">'+data[x].Title+'</a></h2>'; | |
html += '<img src="'+data[x].img+'">'; | |
html += '<h3>Price: '+data[x].price+'</h3>'; | |
html += '</div>'; | |
resultContainer.append(html); | |
} | |
resultContainer.fadeIn('fast'); | |
}); | |
} | |
}); | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<title>Amazon ECS Demo - Product Search</title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script type="text/javascript" src="assets/js/ama_functions.js"></script> | |
<style> | |
body { | |
font-family: Arial, Tahoma, Verdana; | |
padding: 0px; | |
margin: 0px; | |
} | |
.res-container { | |
width: 165px; | |
height: 350px; | |
border: 1px solid #cfcfcf; | |
padding: 10px; | |
text-align: center; | |
float: left; | |
margin-left: 10px; | |
margin-top: 10px; | |
} | |
.res-container h2 { | |
padding: 0px; | |
margin: 0 0 10px 0; | |
height: 115px; | |
} | |
.res-container h2 a { | |
color: #000; | |
} | |
#search-bar { | |
width: 100%; | |
background: #d3d3d3; | |
border-bottom: 1px solid #000; | |
margin-bottom: 30px; | |
height: 70px; | |
} | |
#search-bar input, select { | |
width: 300px; | |
font-size: 15px; | |
font-weight: bold; | |
border: 0px dashed #000; | |
padding: 10px; | |
} | |
#search-bar select { | |
width: 100px !important; | |
} | |
#page { | |
width: 20px !important; | |
} | |
#results, #search-bar { | |
padding-top: 20px; | |
padding-left: 30px; | |
} | |
#search-link { | |
font-size: 25px; | |
font-weight: bold; | |
margin-left: 10px; | |
} | |
span.caption { | |
margin-left: 30px; | |
font-size: 15px; | |
font-weight: bold; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="search-bar"> | |
<span class="caption" style="margin-left: 2px !important">Search:</span> | |
<input type="text" name="search" id="search"> | |
<span class="caption">Category:</span> | |
<select name="category" id="category"> | |
<option value="Blended">ALL</option> | |
<option value="Books">Books</option> | |
<option value="DVD">DVD</option> | |
<option value="Apparel">Apparel</option> | |
<option value="Automotive">Automotive</option> | |
<option value="Electronics">Electronics</option> | |
<option value="GourmetFood">GourmetFood</option> | |
<option value="Kitchen">Kitchen</option> | |
<option value="Music">Music</option> | |
<option value="PCHardware">PCHardware</option> | |
<option value="PetSupplies">PetSupplies</option> | |
<option value="Software">Software</option> | |
<option value="SoftwareVideoGames">SoftwareVideoGames</option> | |
<option value="SportingGoods">SportingGoods</option> | |
<option value="Tools">Tools</option> | |
<option value="Toys">Toys</option> | |
<option value="VHS">VHS</option> | |
<option value="VideoGames">VideoGames</option> | |
</select> | |
<span class="caption">Country:</span> | |
<select name="country" id="country"> | |
<option value="de">DE</option> | |
<option value="com">USA</option> | |
<option value="co.uk">ENG</option> | |
<option value="ca">CA</option> | |
<option value="fr">FR</option> | |
<option value="co.jp">JP</option> | |
<option value="it">IT</option> | |
<option value="cn">CN</option> | |
<option value="es">ES</option> | |
</select> | |
<span class="caption">Browse page:</span> | |
<input type="text" name="page" id="page" value="1"> | |
<a href="#" id="search-link">Search</a> | |
</div> | |
<div id="results"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "include/sampleSettings.php"; | |
require_once "vendor/lib/AmazonECS.class.php"; | |
$amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'DE', AWS_ASSOCIATE_TAG); | |
$amazonEcs->category($_GET['category']); | |
$amazonEcs->responseGroup('Large'); | |
$amazonEcs->returnType(AmazonECS::RETURN_TYPE_ARRAY); | |
$amazonEcs->country($_GET['country']); | |
$page = (!empty($_GET['page'])) ? (int) $_GET['page'] : 1; | |
if ($page === 0) | |
$page = 1; | |
$output = array(); | |
$amazonEcs->page($page); | |
$response_final = $amazonEcs->search($_GET['q']); | |
foreach ($response_final['Items']['Item'] as $singleItem) | |
{ | |
$data = array(); | |
$title = $singleItem['ItemAttributes']['Title']; | |
if (mb_strlen($title) > 30) | |
{ | |
$title = substr($title,0, 30); | |
} | |
$data['Title'] = $title; | |
$data['url'] = $singleItem['DetailPageURL']; | |
$data['img'] = $singleItem['MediumImage']['URL']; | |
$data['price'] = $singleItem['ItemAttributes']['ListPrice']['FormattedPrice']; | |
$output[] = $data; | |
} | |
echo json_encode($output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please reply
i request you.
Associate_tag necessary required