0) {
$parameters['AWSAccessKeyId'] = $access_key;
}
ksort($parameters); // The new authentication requirements need the keys to be sorted
foreach ($parameters as $parameter => $value) { // Create our new request
// We need to be sure we properly encode the value of our parameter
$parameter = str_replace("%7E", "~", rawurlencode($parameter));
$value = str_replace("%7E", "~", rawurlencode($value));
$request_array[] = $parameter . '=' . $value;
}
// Put our & symbol at the beginning of each of our request variables and put it in a string
$new_request = implode('&', $request_array);
// Create our signature string
$signature_string = "GET\n{$uri_elements['host']}\n{$uri_elements['path']}\n{$new_request}";
// Create our signature using hash_hmac
$signature = urlencode(base64_encode(hash_hmac('sha256', $signature_string, $secret_key, true)));
// Return our new request
return "http://{$uri_elements['host']}{$uri_elements['path']}?{$new_request}&Signature={$signature}";
}
function amazonx_construct_request($asin, $access_key, $assoc_tag, $response_group)
{
$ret = "http://ecs.amazonaws.com/onca/xml?" .
"Service=AWSECommerceService" .
"&AWSAccessKeyId={$access_key}" .
"&Operation=ItemLookup" .
"&ItemId={$asin}" .
"&ResponseGroup={$response_group}";
if($assoc_tag != "") {
$ret .= "&AssociateTag={$assoc_tag}";
}
return $ret . "&Version=2010-11-01";
}
function amazonx_image_dir() {
return plugins_url('/images', __FILE__);
}
function amazonx_star_html($rating)
{
if($rating == 0) // code for "no rating"
return "";
$filled_style = "";
$filled_color = get_option('amazonx_starcolor');
if($filled_color != "")
$filled_style = 'style="color: ' . $filled_color . ';" ';
$empty_style = "";
$empty_color = get_option('amazonx_estarcolor');
if($empty_color != "")
$empty_style = 'style="color: ' . $empty_color . ';" ';
$ret = '';
return $ret;
}
function amazonx_below_image_html($asin, $rating)
{
$below = '
'; // default
$code = get_option('amazonx_belowimg');
if($code != "") {
if((int)$code == 0)
$below = '
Amazon Express is not yet configured. Click here to access the configuration page.