i am trying to create an app to look up multiple items. I can run the code with a single variable for an item but as soon as make the variable an array and run foreach loop it is giving me rawurlencode erros. it states that the first line must be a string. Bit confused as to where to go from here.
x = array(744750545472, 705911706019);
foreach ($x as $value) {
$params = array(
"Service" => "AWSECommerceService",
"Operation" => "ItemLookup",
"AWSAccessKeyId" => "ACCESSKEY",
"AssociateTag" => "eledesmaj@example.com",
"ItemId" => $x,
"IdType" => "UPC",
"ResponseGroup" => "ItemAttributes,OfferFull,Offers,SalesRank",
"SearchIndex" => "All"
);
// 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
".$endpoint."
".$uri."
".$canonical_query_string;
// Generate the signature required by the Product Advertising API
$signature = base64_encode(hash_hmac("sha256", $string_to_sign,
List item
aws_secret_key, true));
// Generate the signed URL
$request_url = 'http://'.$endpoint.$uri.'?'.$canonical_query_string.'&Signature='.rawurlencode($signature);
$data = simplexml_load_file($request_url);
echo $data->Items->Item->ASIN;