private function _generateSignature($parameters = array())
    {
        $this->_headers = [];
        $canonical_uri = '/';

        $parameters['Action'] = $this->_action;
        ksort($parameters);

        $request_parameters = http_build_query($parameters, '', '&', PHP_QUERY_RFC3986);

        $canonical_headers = 'host:' . $this->_host . "\n" . 'x-amz-date:' . $this->_amz_date . "\n";
        $signed_headers = 'host;x-amz-date';
        $payload_hash = hash('sha256', '');

        // task1
        $canonical_request = $this->_method . "\n" . $canonical_uri . "\n" . $request_parameters . "\n" . $canonical_headers . "\n" . $signed_headers . "\n" . $payload_hash;

        // task2
        $credential_scope = $this->_date . '/' . $this->_region . '/' . self::SERVICE . '/aws4_request';
        $string_to_sign =  self::ALGORITHM . "\n" . $this->_amz_date . "\n" . $credential_scope . "\n" . hash('sha256', $canonical_request);

        // task3
        $signing_key = $this->_generateSignatureKey();
        $signature = hash_hmac('sha256', $string_to_sign, $signing_key);
        $this->_headers['Authorization'] = self::ALGORITHM . ' Credential=' . $this->_aws_key . '/' . $credential_scope . ', SignedHeaders=' . $signed_headers . ', Signature=' . $signature;
        $this->_headers['x-amz-date'] = $this->_amz_date;
        $this->_query_parameters = $request_parameters;
    }
private function _generateSignature($parameters = array())
    {
        $this->_headers = [];
        $canonical_uri = '/';

        $parameters['Action'] = $this->_action;
        ksort($parameters);

        $request_parameters = http_build_query($parameters, '', '&', PHP_QUERY_RFC3986);

        $canonical_headers = 'host:' . $this->_host . "\n" . 'x-amz-date:' . $this->_amz_date . "\n";
        $signed_headers = 'host;x-amz-date';
        $payload_hash = hash('sha256', '');

        // task1
        $canonical_request = $this->_method . "\n" . $canonical_uri . "\n" . $request_parameters . "\n" . $canonical_headers . "\n" . $signed_headers . "\n" . $payload_hash;

        // task2
        $credential_scope = $this->_date . '/' . $this->_region . '/' . self::SERVICE . '/aws4_request';
        $string_to_sign =  self::ALGORITHM . "\n" . $this->_amz_date . "\n" . $credential_scope . "\n" . hash('sha256', $canonical_request);

        // task3
        $signing_key = $this->_generateSignatureKey();
        $signature = hash_hmac('sha256', $string_to_sign, $signing_key);
        $this->_headers['Authorization'] = self::ALGORITHM . ' Credential=' . $this->_aws_key . '/' . $credential_scope . ', SignedHeaders=' . $signed_headers . ', Signature=' . $signature;
        $this->_headers['x-amz-date'] = $this->_amz_date;
        $this->_query_parameters = $request_parameters;
    }
private function _generateSignature ( $ parameters = array ( ) ) { $ this -> _headers = [ ] ; $ canonical_uri = '/' ; $ parameters [ 'Action' ] = $ this -> _action ; ksort ( $ parameters ) ; $ request_parameters = http_build_query ( $ parameters , '' , '&' , PHP_QUERY_RFC3986 ) ; $ canonical_headers = 'host:' . $ this -> _host . "\n" . 'x-amz-date:' . $ this -> _amz_date . "\n" ; $ signed_headers = 'host;x-amz-date' ; $ payload_hash = hash ( 'sha256' , '' ) ; // task1 $ canonical_request = $ this -> _method . "\n" . $ canonical_uri . "\n" . $ request_parameters . "\n" . $ canonical_headers . "\n" . $ signed_headers . "\n" . $ payload_hash ; // task2 $ credential_scope = $ this -> _date . '/' . $ this -> _region . '/' . self :: SERVICE . '/aws4_request' ; $ string_to_sign = self :: ALGORITHM . "\n" . $ this -> _amz_date . "\n" . $ credential_scope . "\n" . hash ( 'sha256' , $ canonical_request ) ; // task3 $ signing_key = $ this -> _generateSignatureKey ( ) ; $ signature = hash_hmac ( 'sha256' , $ string_to_sign , $ signing_key ) ; $ this -> _headers [ 'Authorization' ] = self :: ALGORITHM . ' Credential=' . $ this -> _aws_key . '/' . $ credential_scope . ', SignedHeaders=' . $ signed_headers . ', Signature=' . $ signature ; $ this -> _headers [ 'x-amz-date' ] = $ this -> _amz_date ; $ this -> _query_parameters = $ request_parameters ; }
Signing AWS Requests with Signature Version 4

@param array $parameters It contains request parameters.

@ref http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html

@return void
Signing AWS Requests with Signature Version 4