Solved

Amazon AWS to get product picture.

Posted on 2016-10-06
9
57 Views
Last Modified: 2016-10-10
I have AccessKeyID for AWS.
I tried following. How can I get Signature? ( I request to provide help here itself, not just link to documents, as I have read all documents but could not get it. Thanks)

http://webservices.amazon.com/onca/xml?
  Service=AWSECommerceService
  &Operation=ItemLookup
  &ResponseGroup=Images
  &IdType=ASIN&
  &ItemId=B004HO6I4M
  &AWSAccessKeyId=[Your_AWSAccessKeyID]
  &AssociateTag=[Your_AssociateTag]
  &Timestamp=[YYYY-MM-DDThh:mm:ssZ]
  &Signature=[Request_Signature]
0
Comment
Question by:Rajesh Joshi
  • 5
  • 4
9 Comments
 
LVL 32

Accepted Solution

by:
shalomc earned 500 total points
Comment Utility
You need to create a sorted canonicalized query string and encrypt the full request  with your private key.
This code is untested, as I don't have a merchant account.

function createAWSSignature($operation,$secret_key){
    return base64_encode(hash_hmac("sha256",$operation,$secret_key,true));
}

$method = "GET";
$host = "webservices.amazon.com";
$uri = "/onca/xml";

// additional parameters
$params["Service"] = "AWSECommerceService";
// GMT timestamp
$params["Timestamp"] = gmdate("Y-m-d\TH:i:s\Z");
$params["Version"] = "2013-08-01";
$params["Operation"] = "ItemLookup";
$params["ResponseGroup"] = "Images";
$params["IdType"] = "ASIN";
$params["ItemId"] = "B004HO6I4M";
$params["AWSAccessKeyId"] = [Your_AWSAccessKeyID];
$params["AssociateTag"] = [Your_AssociateTag];

$AWSPrivateKey=[Your_AWSPrivateKey] ; 

// sort the parameters
ksort($params);

// create the canonicalized query
$canonicalized_array = array();
foreach ($params as $param=>$value)
{
    $value = rawurlencode($value);
    $canonicalized_array[] = $param."=".$value;
}
$canonicalized_query = implode("&", $canonicalized_array);

// create the string to sign

$string_to_sign = $method."\n".$host."\n".$uri."\n".$canonicalized_query;
$signature=createAWSSignature($string_to_sign,$AWSPrivateKey);

Open in new window

0
 
LVL 1

Author Comment

by:Rajesh Joshi
Comment Utility
Thank you shalomc, but I realized that direct using get method is not secured. So can you help me to suggest direct php function to retrieve image URL directly?
0
 
LVL 1

Author Comment

by:Rajesh Joshi
Comment Utility
I mean how to parse the response to get the image url.
0
 
LVL 32

Expert Comment

by:shalomc
Comment Utility
Hey

This is a different matter, probably worthy of a different subject.
Do you have a response example?
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Author Comment

by:Rajesh Joshi
Comment Utility
No. Kindly send a response example.
Thanks a lot.
0
 
LVL 32

Expert Comment

by:shalomc
Comment Utility
I don't have the merchant account that you have, so can't send you a response example.
I suggest that you get a response example using the code from above, and then we can discuss how to read it.
0
 
LVL 1

Author Comment

by:Rajesh Joshi
Comment Utility
Actually I need product image from ASIN value. (not Only Signature )
So can you help me getting function like
function getPictureUrl($ASIN){
    return getPictureUrl;
}
0
 
LVL 32

Expert Comment

by:shalomc
Comment Utility
It is actually bad practice in Experts-Exchange to change the subject of a question in the middle of a thread.
This one started as a question on how to create signed API calls, and morphed into requests to parse some API responses. I suggest that you close this question, and open a new one about finding the image URL. In this way future EE users will search and find relevant answers.  

Cheers
0
 
LVL 1

Author Closing Comment

by:Rajesh Joshi
Comment Utility
Thanks.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article provides a guide on how to optimise your costs within your AWS infrastructure when using some of the common services such as EC2, EBS, S3, Glacier, CloudFront, EIP & ELB.
Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now