Solved

Amazon AWS to get product picture.

Posted on 2016-10-06
9
65 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 500 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
 
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 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

16 Experts available now in Live!

Get 1:1 Help Now