Amazon web services AWS-Guzzle我们计算的请求签名与您提供的签名不匹配。检查您的AWS秘密访问密钥和签名方法
我正在使用SignatureV4 aws身份验证来验证我的API调用, 我还使用Guzzle/Client来调用API 通过遵循上述步骤,我的API调用仅适用于GET方法,而不适用于POST方法。对于POST方法调用,它显示错误(我们计算的请求签名与您提供的签名不匹配。请检查您的AWS秘密访问密钥和签名方法) 我的代码:Amazon web services AWS-Guzzle我们计算的请求签名与您提供的签名不匹配。检查您的AWS秘密访问密钥和签名方法,amazon-web-services,aws-api-gateway,guzzle,guzzlehttp,psr-7,Amazon Web Services,Aws Api Gateway,Guzzle,Guzzlehttp,Psr 7,我正在使用SignatureV4 aws身份验证来验证我的API调用, 我还使用Guzzle/Client来调用API 通过遵循上述步骤,我的API调用仅适用于GET方法,而不适用于POST方法。对于POST方法调用,它显示错误(我们计算的请求签名与您提供的签名不匹配。请检查您的AWS秘密访问密钥和签名方法) 我的代码: use Aws\Credentials\CredentialProvider; use Aws\Signature\SignatureV4; use GuzzleHttp\Cl
use Aws\Credentials\CredentialProvider;
use Aws\Signature\SignatureV4;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
$request = new Request(
'POST',
'https://XXXXXXXXXXXXx.com/XXXXXx/XXXXXXx',
[
'body' => '{
"param1": "loream",
"param2": "4970",
"param3": "1",
"param4": "2.0",
"param5": "mL",
"param6": "kgs",
"param7": 0,
}'
]
);
$key['credentials'] = array(
'key' => 'XXXXXXXXXXXXXXX-access-key',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX-secret-key'
);
$credentials = call_user_func(CredentialProvider::defaultProvider(
$key
));
// Construct a request signer
$signer = new SignatureV4('execute-api',
'us-east-1'
);
// Sign the request
$request = $signer->signRequest($request, $credentials);
// Send the request
try {
$response = (new Client)->send($request);
print_r($response);
}
catch (Exception $exception) {
$responseBody = $exception->getResponse()->getBody(true);
echo $responseBody;
}
$response = (new Client)->send($request);
$results = json_decode($response->getBody());
此问题已解决,Request()中存在语法错误,这应遵循传递的参数的顺序。我得到此错误:致命错误:未捕获类型错误:传递给Aws\Signature\SignatureV4::signRequest()的参数2必须是Aws\Credentials\CredentialsInterface的实例,GuzzleHttp\Promise\Promise的实例