【问题标题】:AWS SDK PHP2- Guzzle Service BuilderAWS SDK PHP2- Guzzle 服务构建器
【发布时间】:2013-08-05 15:02:10
【问题描述】:

我正在尝试摆脱当前的身份验证模型:

$s3_cfg = S3Client::factory(array(
    'key' => 'access',
    'secret' => 'secret'
             ));

改用 Guzzle Service 模型 (http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/service-s3.html#service-locator)

这是我目前所拥有的:

require '../s3up/vendor/autoload.php';
 use Aws\Common\Aws;
 $aws = Aws::factory('api.json');
 $client = $aws>get('apiauth');

还有我的 api.json:

{
"includes": ["_aws"],
"services": {
  "apiauth": {
      "params": {
          "key": "access",
          "secret": "secret",
          "region": "us-west-2"
      }
  }
}
}

出于任何原因,我收到错误 500 和以下错误消息:

 Class '' not found in /s3up/vendor/guzzle/guzzle/src/Guzzle/Service/Builder/ServiceBuilder.php on line 141

我使用 composer 安装了 AWS php SDK2。如果我只是删除服务定位器并改用基本身份验证,一切都很好,所以我的 autoload.php 没有任何问题

我从 http://docs.aws.amazon.com/awssdkdocsphp2/latest/gettingstartedguide/sdk-php2-using-the-sdk.html#sdk-php2-using-the-service-builder 获得 JSON 语法

谢谢

【问题讨论】:

    标签: php amazon-web-services amazon-s3 guzzle


    【解决方案1】:

    如果您希望这些密钥用于构建器创建的所有服务,则应将“apiauth”更改为“default_settings”。然后,您将调用 $aws->get('s3') 以获取具有共享凭证的 Amazon S3 客户端。

    【讨论】:

    • 谢谢 Michael :) 顺便说一句:如果有人想重用我的代码,请务必更新: $client = $aws>get('s3'); with $client = $aws->get('s3');
    猜你喜欢
    • 2013-06-03
    • 2015-05-10
    • 1970-01-01
    • 2020-05-13
    • 2022-01-13
    • 1970-01-01
    • 2012-01-03
    • 2018-11-20
    • 2010-11-15
    相关资源
    最近更新 更多