dozug64282 2014-03-24 14:33
浏览 378
已采纳

AWS SDK中找不到GetSessionToken命令

I have the following code

<?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);

?>

However, it's resulting in this error:

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

The issue is with this line:

$result = $sts->getSessionToken();

I've been following this guide: http://docs.aws.amazon.com/AmazonS3/latest/dev/AuthUsingTempSessionTokenPHP.html

I don't see any reason for the error to be occurring. Is there any reason for this, or a way to fix it?

  • 写回答

1条回答 默认 最新

  • dronthpi05943 2014-03-24 14:38
    关注

    You are mixing the example up. S3Client::factory() expects a token as a param. You maybe should be using StsClient::factory()?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 专家修改了标签 8月18日

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!