public function itemSearch($SearchIndex, $Keywords) { //Set the values for some of the parameters $Operation = "ItemSearch"; $Version = "2015-07-20"; $ResponseGroup = "ItemAttributes,Offers"; //User interface provides values //for $SearchIndex and $Keywords //Define the request $request = "http://webservices.amazon.com/onca/xml" . "?Service=AWSECommerceService" . "&AssociateTag=" . Associate_tag . "&AWSAccessKeyId=" . Access_Key_ID . "&Operation=" . $Operation . "&Version=" . $Version . "&SearchIndex=" . $SearchIndex . "&Keywords=" . $Keywords . "&Signature=" . Request_Signature . "&ResponseGroup=" . $ResponseGroup; //Catch the response in the $response object $response = file_get_contents($request); $parsed_xml = simplexml_load_string($response); printSearchResults($parsed_xml, $SearchIndex); }
include_once 'header.php'; ?> <?php include_once 'menu.php'; ?> <div id="main"> <div class="container"> <div class="news"> <div class="box"> <?php if (isset($_GET['word'])) { ?> <h1>Search results...</h1> <?php printSearchResults($_GET['word']); } ?> </div> </div> <div class="sidebar"> <?php include_once 'userbox.php'; ?> <?php include_once 'commentsbox.php'; ?> </div>
function ItemSearch($searchIndex, $keywords, $itemPage = 1) { global $wgMemc; $memKey = wfMemcKey('LW_AMZN_ITEM_SEARCH', str_replace(" ", "_", $keywords), $searchIndex, $itemPage); $response = $wgMemc->get($memKey); if (empty($response)) { // TODO: REMOVE - This was the old method before signing requests. // $request="http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=ItemSearch&ResponseGroup=Medium,Offers"; // $request.="&SearchIndex=$searchIndex&Keywords=$keywords&ItemPage=$itemPage"; // NOTE: Instead of "Keywords", can also do "Artist" if desired. For now just leaving it as-is since we're already searching in DigitalMusic. $params = array("Operation" => "ItemSearch", "SearchIndex" => $searchIndex, "Keywords" => $keywords, "ItemPage" => $itemPage); $request = aws_signed_request($params, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY); $response = Http::get($request); $wgMemc->set($memKey, $response, SECONDS_IN_A_DAY); } $parsed_xml = simplexml_load_string($response); printSearchResults($parsed_xml, $searchIndex, $itemPage); }