Solved

Amazon AWS to get product picture.

Posted on 2016-10-06
9
79 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP strings vs array errors 13 33
hbo knew my windows software 4 62
Integrating Amazon Alexa,  google sheet, and Twilio msg 2 19
PHP and MSSQL Arrays and Variables 3 25
AWS Glacier is Amazons cheapest storage option and is their answer to a ‘Cold’ storage service.  Customers primarily use this service for archival purposes and storage of infrastructure backups.  Its unlimited storage potential and low storage cost …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
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.

827 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