[英]GetSessionToken command not found in AWS SDK
我有以下代碼
<?php
require '../aws/aws-autoloader.php';
use Aws\Sts\StsClient;
use Aws\S3\S3Client;
$sts = S3Client::factory(array(
'key' => 'key',
'secret' => 'key',
));
$result = $sts->getSessionToken();
$credentials = $result->get('Credentials');
print_r($credentials);
?>
但是,它導致了這個錯誤:
Uncaught exception 'Guzzle\Common\Exception\InvalidArgumentException' with message 'Command was not found matching GetSessionToken' in /home/site/public_html/dev/testAWS/core/aws/Guzzle/Service/Client.php:87 Stack trace: #0 /home/site/public_html/dev/testAWS/core/aws/Guzzle/Service/Client.php(76): Guzzle\Service\Client->getCommand('GetSessionToken', Array) #1 /home/site/public_html/dev/testAWS/core/aws/Aws/Common/Client/AbstractClient.php(105): Guzzle\Service\Client->__call('GetSessionToken', Array) #2 /home/site/public_html/dev/testAWS/core/ajax/test2.php(13): Aws\Common\Client\AbstractClient->__call('getSessionToken', Array) #3 /home/site/public_html/dev/testAWS/core/ajax/test2.php(13): Aws\S3\S3Client->getSessionToken() #4 {main} thrown in /home/site/public_html/dev/testAWS/core/aws/Guzzle/Service/Client.php on line 87
問題在於這一行:
$result = $sts->getSessionToken();
我一直在關注這個指南: http : //docs.aws.amazon.com/AmazonS3/latest/dev/AuthUsingTempSessionTokenPHP.html
我沒有看到任何錯誤發生的原因。 這有什么理由,還是一種解決方法?
你正在混合這個例子。 S3Client :: factory()需要一個標記作為參數。 您可能應該使用StsClient :: factory()?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.