Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Amazon AWS to get product picture.

Posted on 2016-10-06
9
Medium Priority
?
123 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 33

Accepted Solution

by:
shalomc earned 2000 total points
ID: 41833555
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
ID: 41834003
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
ID: 41834146
I mean how to parse the response to get the image url.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 33

Expert Comment

by:shalomc
ID: 41834397
Hey

This is a different matter, probably worthy of a different subject.
Do you have a response example?
0
 
LVL 1

Author Comment

by:Rajesh Joshi
ID: 41834617
No. Kindly send a response example.
Thanks a lot.
0
 
LVL 33

Expert Comment

by:shalomc
ID: 41835423
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
ID: 41835801
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 33

Expert Comment

by:shalomc
ID: 41836008
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
ID: 41836601
Thanks.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

824 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