/** * Performs the soaprequest * * @param OperationInterface $operation The operation * @param array $params Requestparameters 'ParameterName' => 'ParameterValue' * * @return array The response as an array with stdClass objects */ protected function performSoapRequest(OperationInterface $operation, $params) { $soapClient = new \SoapClient($this->webserviceWsdl, array('exceptions' => 1)); $soapClient->__setLocation(str_replace('%%COUNTRY%%', $this->configuration->getCountry(), $this->webserviceEndpoint)); $soapClient->__setSoapHeaders($this->buildSoapHeader($operation)); return $soapClient->__soapCall($operation->getName(), array($params)); }
/** * Builds the final querystring including the signature * * @param array $params * @param ConfigurationInterface $configuration * * @return string */ protected function buildQueryString(array $params, ConfigurationInterface $configuration) { $parameterList = []; foreach ($params as $key => $value) { $parameterList[] = sprintf('%s=%s', $key, rawurlencode($value)); } $parameterList[] = 'Signature=' . rawurlencode($this->buildSignature($parameterList, $configuration->getCountry(), $configuration->getSecretKey())); return implode("&", $parameterList); }
/** * Calculates the signature for the request * * @param array $params * * @return string */ protected function buildSignature(array $params) { $template = "GET\nwebservices.amazon.%s\n/onca/xml\n%s"; return Util::buildSignature(sprintf($template, $this->configuration->getCountry(), implode('&', $params)), $this->configuration->getSecretKey()); }