0

I have some trouble to get a simple xml answer from Amazon, it reports me always:

Sender
    InvalidParameterValue
    Either Action or Operation query parameter must be present.

And if I ask their Support, they can't help me they dont see the missing Parameter... Their suggestion is follow their Examples, but my Webhost only supports php 5.2, so the autoloader doesn't work.

<?php
#header("Content-Type:text/xml");
$sellerID = 'SELLEDERID';
$aws = 'AWSKEY';
$secret = 'SECRET';


$action = 'GetReportList';

$timestamp = gmdate("Y-m-d\TH:i:s\Z");
$signature = $action . $timestamp;
$sig = base64_encode(hash_hmac("sha256", $signature, $secret, true));
$service = 'https://mws.amazonservices.com/?';

$url  = 'AWSAccessKeyId='.$aws;
$url .= '&Action='.$action;
$url .= '&Merchant='.$sellerid;
$url .= '&SignatureVersion=2';
$url .= '&Timestamp=2013-01-10T12:22:48Z';
$url .= '&Version=2009-01-01';
$url .= '&Signature='.$sig;
$url .= '&SignatureMethod=HmacSHA256';
$awsURL = $service.urlencode($url);

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $awsURL,
    CURLOPT_USERAGENT => 'Request'
));
$resp = curl_exec($curl);
curl_close($curl);
echo "<pre>";
var_dump($resp);
var_dump($awsURL);
echo "</pre>";
?> 
chris
  • 403
  • 3
  • 10
  • can you expand on "they don't see the missing parameter"? Did they confirm that your url contains the correct paramters? Or just send you back to their examples? – chris Jan 10 '13 at 13:23
  • your web host needs to upgrade -- PHP5.2 has been unsupported for two years; it has known security flaws that have not and *will not* be fixed. No server admin worth his pay would allow it to still be running on his servers. If your web host is willing to run software on their servers that is obsolete and known to be insecure then they clearly don't care about their users; you're using the wrong web host. – SDC Jan 10 '13 at 13:36
  • @Chris, they said only "we see no error in your Request", but i built the Query with Amazon Scratchpad (https://mws.amazonservices.com/scratchpad/index.html) – alphazuluger Jan 10 '13 at 13:40
  • @SDC, i know this but the Software on the Webspace is encrypted using ZEND and needs PHP 5.2. – alphazuluger Jan 10 '13 at 13:41
  • by the way, you say the autoloader doesn't work because you're using 5.2... but PHP 5.2 does support autoloaders. – SDC Jan 10 '13 at 13:59

1 Answers1

0

The "we see no error in your request" probably referred to the request you put into Scratchpad, and not to the request you made through php, because your signature calculation is way off.

See this StackOverflow question or the MWS Developers Guide (page 12, "If you create your own client library") on how to calculate the sig.

The actual error message seems weird. I expect it to change once you've got your signature right. Please also note that quite a few MWS API calls require a HTTP POST, so if you intend to reuse that code in other places you're probably better off changing your code accordingly.

Community
  • 1
  • 1
Hazzit
  • 6,782
  • 1
  • 27
  • 46