I'm using the PHP AWS SDK and would like to list all buckets available to me in S3.
I found a few different blocks of documentation that look promising:
Here's what I'm trying, using the AWS Service Builder to initialize an S3 client...
use Aws\Common\Aws;
// Instantiate an S3 client
$aws = Aws::factory(array( 'key' => "MY_KEY", 'secret' => "MY_SECRET"));
$s3 = $aws->get('s3');
$s3->get_bucket_list();
Unfortunately when I run the code I am told that it has no freakin' clue what "get_buckets_list" is. More specifically it says
Fatal error: Uncaught exception 'Guzzle\Common\Exception\InvalidArgumentException' with message 'Command was not found matching GetBucketList' in vendor/guzzle/guzzle/src/Guzzle/Service/Client.php:87
So my questions are as follows:
The documentation for this call can be found here.
$result = $s3->listBuckets(array());
foreach ($result['Buckets'] as $bucket) {
echo $bucket['Name'], PHP_EOL;
}
I suspect that you were mixing up two different API's :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With