/** * Provides some necessary soap headers * * @param OperationInterface $operation * * @return array Each element is a concrete SoapHeader object */ protected function buildSoapHeader(OperationInterface $operation) { $timeStamp = Util::getTimeStamp(); $signature = $this->buildSignature($operation->getName() . $timeStamp); return array(new \SoapHeader('http://security.amazonaws.com/doc/2007-01-01/', 'AWSAccessKeyId', $this->configuration->getAccessKey()), new \SoapHeader('http://security.amazonaws.com/doc/2007-01-01/', 'Timestamp', $timeStamp), new \SoapHeader('http://security.amazonaws.com/doc/2007-01-01/', 'Signature', $signature)); }
/** * Prepares the parameters for the request * * @param OperationInterface $operation * @param ConfigurationInterface $configuration * * @return array */ protected function prepareRequestParams(OperationInterface $operation, ConfigurationInterface $configuration) { $baseRequestParams = ['Service' => 'AWSECommerceService', 'AWSAccessKeyId' => $configuration->getAccessKey(), 'AssociateTag' => $configuration->getAssociateTag(), 'Operation' => $operation->getName(), 'Version' => '2013-08-01', 'Timestamp' => Util::getTimeStamp()]; $operationParams = $operation->getOperationParameter(); foreach ($operationParams as $key => $value) { if (true === is_array($value)) { $operationParams[$key] = implode(',', $value); } } $fullParameterList = array_merge($baseRequestParams, $operationParams); ksort($fullParameterList); return $fullParameterList; }
public function testTimestamp() { $this->assertRegExp('#[0-9]{4}(-[0-9]{2}){2}T([0-9]{2}:){2}[0-9]{2}Z#', Util::getTimeStamp()); }