PHP code example of hdgtxcloud / tencentcloud-sdk-php

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

    

hdgtxcloud / tencentcloud-sdk-php example snippets



Hdgtxcloud\Cvm\V20170312\Models\DescribeInstancesRequest;
use Hdgtxcloud\Common\Exception\TencentCloudSDKException;
use Hdgtxcloud\Common\Credential;

try {
    $cred = new Credential("secretId", "secretKey");
    $client = new CvmClient($cred, "ap-guangzhou");
    $req = new DescribeInstancesRequest();
    $resp = $client->DescribeInstances($req);
    print_r($resp->toJsonString());
}
catch(TencentCloudSDKException $e) {
    echo $e;
}

$cred = new Credential("secretId", "secretKey");

$httpProfile = new HttpProfile();
$httpProfile->setProxy('https://ip:port');

$clientProfile = new ClientProfile();
$clientProfile->setHttpProfile($httpProfile);

$client = new OcrClient($cred, 'ap-beijing', $this->clientProfile);