Hi, Today i am gonna talk about how to use SDK provided by aws (PHP).
For aws SDK, they support few kind of languages such as Php, Android, IOS , Java, Python. For all the available language for sdk , Click Here
You will have to import aws sdk files there are three kind of method based on this link
P/S :- Php including method only
And Here are some codes to show how to use the sdk.
require "AWS/aws-autoloader.php"; $s3 = new Aws\S3\S3Client([ 'version' => 'latest', 'region' => 'ap-southeast-2' ]); $result = $s3->listBuckets(); print_r($result);
You’ll be wondering Why i do not have to pass the access and secret key into the functions, that is because in my case, i am using the access key and secret key as an enviroment variable. This is the best and most secure of handling credentials. AWS SDK will find enviroment variables (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY ).
On the other hand you can also do this:
require "AWS/aws-autoloader.php"; $s3 = new Aws\S3\S3Client([ 'version' => 'latest', 'region' => 'ap-southeast-2', 'credentials' => array( 'key'=>'YOUR_AWS_ACCESS_KEY_ID', 'secret'=>'YOUR_SECRET_ACCESS_KEY' ) ]); $result = $s3->listBuckets(); print_r($result);