1. Go to this page and download the library: Download alibabacloud/sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alibabacloud / sdk example snippets
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Ecs\Ecs;
// Set up a global client
AlibabaCloud::accessKeyClient('foo', 'bar')
->regionId('cn-hangzhou')
->asDefaultClient();
try {
// Access product APIs
$request = Ecs::v20140526()->describeRegions();
// Set options/parameters and execute request
$result = $request->withResourceType('type') // API parameter
->withInstanceChargeType('type') // API parameter
->client('client1') // Specify the client for send
->debug(true) // Enable the debug will output detailed information
->connectTimeout(0.01) // Throw an exception when Connection timeout
->timeout(0.01) // Throw an exception when timeout
->request(); // Execution request
// Can also Set by passing in an array
$options = [
'debug' => true,
'connect_timeout' => 0.01,
'timeout' => 0.01,
'query' => [
'ResourceType' => 'type',
'InstanceChargeType' => 'type',
],
];
// Settings priority
$result2 = Ecs::v20140526()
->describeRegions($options)
->options([
'query' => [
'Key' => 'I will overwrite this value in constructor',
'new' => 'I am new value',
],
])
->options([
'query' => [
'Key' => 'I will overwrite the previous value',
'bar' => 'I am new value',
],
])
->debug(false) // Overwrite the true of the former
->request();
} catch (ClientException $exception) {
echo $exception->getMessage(). PHP_EOL;
} catch (ServerException $exception) {
echo $exception->getMessage() . PHP_EOL;
echo $exception->getErrorCode(). PHP_EOL;
echo $exception->getRequestId(). PHP_EOL;
echo $exception->getErrorMessage(). PHP_EOL;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.