PHP code example of rjyxz / aliyun-php-sdk-core

1. Go to this page and download the library: Download rjyxz/aliyun-php-sdk-core 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/ */

    

rjyxz / aliyun-php-sdk-core example snippets




use Ecs\Request\V20140526\DescribeInstancesRequest;

# 创建DefaultAcsClient实例并初始化
$clientProfile = DefaultProfile::getProfile(
    "<your-region-id>",                   # 您的 Region ID 
    "<your-access-key-id>",               # 您的 AccessKey ID
    "<your-access-key-secret>"            # 您的 AccessKey Secret
);
$client = new DefaultAcsClient($clientProfile);

# 创建API请求并设置参数
$request = new DescribeInstancesRequest();
$request->setPageSize(10);

# 发起请求并处理返回
try {
    $response = $client->getAcsResponse($request);
    print_r($response);
} catch(ServerException $e) {
    print "Error: " . $e->getErrorCode() . " Message: " . $e->getMessage() . "\n";
} catch(ClientException $e) {
    print "Error: " . $e->getErrorCode() . " Message: " . $e->getMessage() . "\n";
}