|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
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.
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
Execute one of the
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.
use Aws\S3\S3Client; // Instantiate the S3 client with your AWS credentials $s3 = S3Client::factory(array( 'key' => '
*** Your AWS Access Key ID ***', 'secret' => '
*** Your AWS Secret Key ***' )); $result = $s3->listBuckets();
You can provide your access keys as shown in the preceding example,
or you can omit the keys if you are using
AWS Identity and Access Management (IAM) roles for Amazon EC2
instances or credentials sourced from the
AWS_SECRET_ACCESS_KEY environment variables.
For an example of listing object keys in a bucket, see Listing Keys Using the AWS SDK for PHP.