Here trying to demonstrate a that how to calculate signature for AWS Authorization.
I refer this link to implement the steps as describe https://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
Step 1: Include the file where calculation and cURL implemented within two function.include('./aws_secure_request.php');Step 2: Set the values in configuration variable.
// Configuration values $host = '<your host name>'; $accessKey = '<access key>'; $secretKey = '<secret key>'; $region = '<region>'; $service = '<service>';$requestUrl = '<full url>'; $uri = '<method path>'; $httpRequestMethod = '<http verb>';
For example
$region = 'ap-southeast-1'
$service = 'execute-api'
$requestUrl = 'https://host-domain/object/identifier'
$uri = '/object/identifier'
$httpRequestMethod = 'PUT'
$data = json_encode(array( "username" => "sample-demo", "firstName" => "Sample", "lastName" => "Demo", "date_of_birth" => "1999-05-08" ));Step 4: Now call the method to generate signature get all headers need to send.
$headers = calcualteAwsSignatureAndReturnHeaders( $host, $uri, $requestUrl, $accessKey, $secretKey, $region $service, $httpRequestMethod, $data, TRUE);Step 5: Final step to call API using cURL.
$result = callToAPI( $requestUrl, $httpRequestMethod, $headers, $data, TRUE);Note: Last parameter as TRUE in above two function can be use to show DEBUG information, otherwise just send FALSE.
You can use aws_request_sample.php to start.