繁体   English   中英

AWS SDK中找不到GetSessionToken命令

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM