Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Amazon AWS to get product picture.

Posted on 2016-10-06
9
Medium Priority
?
115 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

670 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