Menu
Amazon Simple Storage Service
Developer Guide (API Version 2006-03-01)

Making Requests Using AWS Account or IAM User Credentials - AWS SDK for PHP

This topic guides you through using a class from the AWS SDK for PHP to send authenticated requests using your AWS account or IAM user credentials.

Note

This topic assumes that you are already following the instructions for Using the AWS SDK for PHP and Running PHP Examples and have the AWS SDK for PHP properly installed.

Making Requests Using Your AWS Account or IAM user Credentials

1

Create an instance of an Amazon S3 client by using the Aws\S3\S3Client class factory() method.

2

Execute one of the Aws\S3\S3Client methods to send requests to Amazon S3. For example, you can use the Aws\S3\S3Client::listBuckets() method to send a request to list all the buckets for your account. The client API generates the necessary signature using your credentials and includes it in the request it sends to Amazon S3.

The following PHP code sample demonstrates the preceding tasks and illustrates how the client makes a request using your security credentials to list all the buckets for your account.

Copy
use Aws\S3\S3Client; // Instantiate the S3 client with your AWS credentials $s3 = S3Client::factory(); $result = $s3->listBuckets();

For working examples, see Working with Amazon S3 Objects and Working with Amazon S3 Buckets. You can test these examples using your AWS account or IAM user credentials.

For an example of listing object keys in a bucket, see Listing Keys Using the AWS SDK for PHP.

On this page: