[Web Service] amazon webservices et paramètre signature
J'ai un souci avec le code ci-dessous :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| $wsdl = "http://webservices.amazon.com/AWSECommerceService/2010-10-01/US/AWSECommerceService.wsdl";
$params = array(
'AWSAccessKeyId' => 'AKIAJHWJRIV57OXSRXFQ',
'AssociateTag' => 'ws',
'Request' => array(
array('SearchIndex' => $searchindex,'Keywords' => $keywords)
)
);
$client = new SoapClient($wsdl,array('exceptions' => FALSE,'soap_version' => SOAP_1_1,'trace' => TRUE));
//var_dump($client->__getFunctions());
$resultat = $client->ItemSearch($params);
if(is_soap_fault($resultat))
{
echo "<br>SOAP fault -> faultcode : " . $resultat->faultcode . " faultstring : " . $resultat->faultstring . " faultactor : " . $resultat->faultactor . "<br>" ;
return FALSE;
}
else
{
echo "<br>Requete SOAP correcte.<br>";
}
echo "<br>";
echo "<h2>Requete</h2><pre>" . htmlspecialchars($client->_getLastRequest(),ENT_QUOTES) . "</pre>";
echo "<h2>Reponse</h2><pre>" . htmlspecialchars($client->_getLastResponse(),ENT_QUOTES) . "</pre>";
echo "<br>"; |
j'obtient le resultat suivant :
faultcode : aws:Client.MissingParameter
faultstring : The request must contain the parameter Signature.
Ce paramètre (Signature) n'apparait pas dans le fichier wsdl au niveau de l'élément ItemSearch.
Il y a t'il un lien avec la Secrete acces key donné par amazon ?
Ajout du parametre signature.
J'ai finalement ajouté le parametre signature à la requete :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| $action = 'ItemSearch';
$timestamp = gmdate('Y-m-d\TH:i:s\Z');
$string = $action . $timestamp;
$signature = base64_encode(hash_hmac('sha256',$string,$secretKey,TRUE));
$params = array(
'AWSAccessKeyId' => 'AKIAJHWJRIV57OXSRXFQ',
'AssociateTag' => 'ws',
'Action' => $action,
'Timestamp' => $timestamp,
'Signature' => $signature,
'Request' => array(
array('SearchIndex' => $searchindex,'Keywords' => $keywords)
)
); |
Mais j'ai toujours la meme erreur qui apparait :
faultcode : aws:Client.MissingParameter faultstring : The request must contain the parameter Signature