'TRANSFER', 'configuration' => ['email' => 'y.oraz@hotmail.com'], 'createdAt' => 1720230432, 'status' => 'PENDING', 'userUuid' => '0950e3c8-02f1-426e-96aa-653644a45176', 'uuid' => '245fada1-4ec7-4495-a9b8-650a5115c339', 'vendor' => 'PAYPAL' ]); // Step 4: Create the canonical headers and signed headers. $canonical_headers = "host:$host\n" . "x-amz-date:$x_amz_date\n" . "x-amz-security-token:$x_amz_security_token\n"; $signed_headers = 'host;x-amz-date;x-amz-security-token'; // Step 6: Create payload hash $payload_hash = hash('sha256', $payload); // Step 7: Combine elements to create canonical request $canonical_request = "$method\n$canonical_uri\n\n$canonical_headers\n$signed_headers\n$payload_hash"; // Step 8: Create the string to sign $algorithm = 'AWS4-HMAC-SHA256'; $credential_scope = "$date/us-east-1/execute-api/aws4_request"; $string_to_sign = "$algorithm\n$x_amz_date\n$credential_scope\n" . hash('sha256', $canonical_request); // Step 9: Calculate the signature function sign($key, $msg) { return hash_hmac('sha256', $msg, $key, true); } function getSignatureKey($key, $dateStamp, $regionName, $serviceName) { $kDate = sign('AWS4' . $key, $dateStamp); $kRegion = sign($kDate, $regionName); $kService = sign($kRegion, $serviceName); $kSigning = sign($kService, 'aws4_request'); return $kSigning; } if ($access_key === null || $secret_key === null) { echo 'No access key is available.'; exit; } $signing_key = getSignatureKey($secret_key, $date, 'us-east-1', 'execute-api'); $signature = hash_hmac('sha256', $string_to_sign, $signing_key); $authorization_header = "AWS4-HMAC-SHA256 Credential=$access_key/$credential_scope, SignedHeaders=$signed_headers, Signature=$signature"; echo "Authorization: $authorization_header\n"; echo "X-Amz-Date: $x_amz_date\n"; echo "X-Amz-Security-Token: $x_amz_security_token\n"; ?>