data_center/vendor/tencentcloud/tencentcloud-sdk-php/examples/cvm/v20170312/DescribeZones.php

30 lines
1.1 KiB
PHP
Raw Normal View History

2023-09-18 09:11:13 +08:00
<?php
require_once __DIR__.'/../../../vendor/autoload.php';
// 导入对应产品模块的client
use TencentCloud\Cvm\V20170312\CvmClient;
// 导入要请求接口对应的Request类
use TencentCloud\Cvm\V20170312\Models\DescribeZonesRequest;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Common\Credential;
use TencentCloud\Common\Profile\ClientProfile;
try {
// 实例化一个证书对象入参需要传入腾讯云账户secretIdsecretKey
$cred = new Credential(getenv("TENCENTCLOUD_SECRET_ID"), getenv("TENCENTCLOUD_SECRET_KEY"));
$clientProfile = new ClientProfile();
//$clientProfile->setLanguage(ClientProfile::$ZH_CN);
$clientProfile->setSignMethod(ClientProfile::$SIGN_HMAC_SHA256);
// # 实例化要请求产品(以cvm为例)的client对象
$client = new CvmClient($cred, "ap-guangzhou", $clientProfile);
// 实例化一个请求对象
$req = new DescribeZonesRequest();
// 通过client对象调用想要访问的接口需要传入请求对象
$resp = $client->DescribeZones($req);
print_r($resp->toJsonString());
}
catch(TencentCloudSDKException $e) {
echo $e;
}