If you want these keys to be used for all of the services that the builder creates, then you should change "apiauth" to "default_settings". You would then call $aws->get('s3')
to get an Amazon S3 client with the shared credentials.
AWS SDK PHP2- Guzzle Service Builder
-
23-06-2022 - |
Question
I'm trying to get rid of my current authenticate model:
$s3_cfg = S3Client::factory(array(
'key' => 'access',
'secret' => 'secret'
));
and use Guzzle Service model instead (http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/service-s3.html#service-locator)
Here is what I have so far:
require '../s3up/vendor/autoload.php';
use Aws\Common\Aws;
$aws = Aws::factory('api.json');
$client = $aws>get('apiauth');
and my api.json:
{
"includes": ["_aws"],
"services": {
"apiauth": {
"params": {
"key": "access",
"secret": "secret",
"region": "us-west-2"
}
}
}
}
For any reason, I'm getting an error 500 and the following error message:
Class '' not found in /s3up/vendor/guzzle/guzzle/src/Guzzle/Service/Builder/ServiceBuilder.php on line 141
I installed AWS php SDK2 using composer. If I just remove the service locator and use basic auth instead, everything is OK, so I don't have any problem with my autoload.php
I get the JSON syntax from http://docs.aws.amazon.com/awssdkdocsphp2/latest/gettingstartedguide/sdk-php2-using-the-sdk.html#sdk-php2-using-the-service-builder
Thanks
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow