"AWSECommerceService",
"Operation" => "ItemSearch",
"AWSAccessKeyId" => "your-access-key",
"AssociateTag" => "your-associate-tag",
"SearchIndex" => "Electronics",
"Keywords" => "best mobile phones",
"Sort" => "salesrank",
"ResponseGroup" => "Images,ItemAttributes,Offers",
"ItemPage" => 1
);
// Set current timestamp if not set
if (!isset($params["Timestamp"])) {
$params["Timestamp"] = gmdate('Y-m-d\TH:i:s\Z');
}
// Sort the parameters by key
ksort($params);
$pairs = array();
foreach ($params as $key => $value) {
array_push($pairs, rawurlencode($key)."=".rawurlencode($value));
}
// Generate the canonical query
$canonical_query_string = join("&", $pairs);
// Generate the string to be signed
$string_to_sign = "GET\n".$host."\n".$uri."\n".$canonical_query_string;
// Generate the signature required by the Product Advertising API
$signature = base64_encode(hash_hmac("sha256", $string_to_sign, $secret_key, true));
// Generate the signed URL
$request_url = 'http://'.$host.$uri.'?'.$canonical_query_string.'&Signature='.rawurlencode($signature);
$response = file_get_contents($request_url);
$parsed_xml = simplexml_load_string($response);
echo "
";
foreach ($parsed_xml->Items->Item as $item) {
echo "
";
echo "
";
echo "
".$item->ItemAttributes->Title."
";
echo "
".$item->ItemAttributes->Feature."
";
echo "
";
}
echo "
";
?>