SecretId and SecretKey. SecretId is used to identify the API requester, while SecretKey is a key used for signature string encryption and authentication by the server. You can get them on the API Key Management page as shown below:

*.tencentcloudapi.com and varies by product. For example, the endpoint of CVM is cvm.tencentcloudapi.com. For specific endpoints, please see the API documentation of the corresponding product .openssl needs to be enabled.curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer config -g repos.packagist composer https://mirrors.tencent.com/composer/
C:\\Users\\···> directory, open the command window at the specified location and run the following command:composer require tencentcloud/tencentcloud-sdk-php
vendor directory in the project root directory, whose actual absolute path is /path/to/ (if you perform this operation in the project root directory, you can omit the absolute path).require '/path/to/vendor/autoload.php';
composer require tencentcloud/product name, such as composer require tencentcloud/cvm.DescribeInstances as an example:<?phprequire_once '/path/to/vendor/autoload.php';use TencentCloud\\Cvm\\V20170312\\Models\\DescribeInstancesRequest;use TencentCloud\\Common\\Exception\\TencentCloudSDKException;use TencentCloud\\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;}
<?phprequire_once '/path/to/vendor/autoload.php';// Import the client of the corresponding product moduleuse TencentCloud\\Cvm\\V20170312\\CvmClient;// Import the `Request` class corresponding to the request APIuse TencentCloud\\Cvm\\V20170312\\Models\\DescribeInstancesRequest;use TencentCloud\\Cvm\\V20170312\\Models\\Filter;use TencentCloud\\Common\\Exception\\TencentCloudSDKException;use TencentCloud\\Common\\Credential;// Import the optional configuration classesuse TencentCloud\\Common\\Profile\\ClientProfile;use TencentCloud\\Common\\Profile\\HttpProfile;try {// Instantiate a certificate object. The Tencent Cloud account `secretId` and `secretKey` need to be passed in as input parameters$cred = new Credential("secretId", "secretKey");// (Optional) Instantiate an HTTP option$httpProfile = new HttpProfile();// Configure the proxy// $httpProfile->setProxy("https://ip:port");$httpProfile->setReqMethod("GET"); // GET request (POST request is used by default)$httpProfile->setReqTimeout(30); // Specify the request timeout value in seconds. The default value is 60s$httpProfile->setEndpoint("cvm.ap-shanghai.tencentcloudapi.com"); // Specify the endpoint. If you do not specify the endpoint, nearby access is enabled by default// Instantiate a client option (optional; skip if no special requirements are present)$clientProfile = new ClientProfile();$clientProfile->setSignMethod("TC3-HMAC-SHA256"); // Specify the signature algorithm. The default value is `HmacSHA256`$clientProfile->setHttpProfile($httpProfile);// Instantiate the client object of the requested product (with CVM as an example). `clientProfile` is optional$client = new CvmClient($cred, "ap-shanghai", $clientProfile);// Instantiate a CVM instance information query request object. Each API corresponds to a request object$req = new DescribeInstancesRequest();// Populate the request parameters. Here, the member variables of the request object are the input parameters of the corresponding API// You can view the definition of the request parameters in the API documentation at the official website or by redirecting to the definition of the request object$respFilter = new Filter(); // Create a `Filter` object to query CVM instances in the `zone` dimension$respFilter->Name = "zone";$respFilter->Values = ["ap-shanghai-1", "ap-shanghai-2"];$req->Filters = [$respFilter]; // `Filters` is a list of `Filter` objects// Initialize the request by calling the `DescribeInstances` method on the client object. Note: the request method name corresponds to the request object// The returned `resp` is an instance of the `DescribeInstancesResponse` class which corresponds to the request object$resp = $client->DescribeInstances($req);// A string return packet in JSON format is outputprint_r($resp->toJsonString());// You can also take a single value// You can view the definition of the return field in the API documentation at the official website or by redirecting to the definition of the response objectprint_r($resp->TotalCount);}catch(TencentCloudSDKException $e) {echo $e;}
https_proxy; otherwise, it may not be called normally, and a connection timeout exception will be thrown. You can also use GuzzleHttp to proxy the configuration:$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);
cURL error 60: See http://curl.haxx.se/libcurl/c/libcurl-errors.html may occur, which can be solved as follows:cacert.pem at https://curl.haxx.se/ca/cacert.pem and save it to the PHP installation path.php.ini file: delete the semicolon comment (;) before the curl.cainfo configuration item and set the value to the absolute path of the saved certificate file cacert.pem./etc/php/7.1/apache2/php.ini to see whether the extension=php_curl.dll configuration item has been commented. Please delete the comment before it and restart Apache.cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)php -r "echo sys_get_temp_dir();" to print the absolute path of the default system temporary directory and set sys_temp_dir in php.ini to this value, and then check whether this error is fixed.vendor directory. However, considering that incompatibility with Composer should not be caused, we had to forbid importing the vendor directory on GitHub, which resulted in the problem where the git clone command had to be used to get the vendor directory. This practice caused confusion for some users not familiar with GitHub. Therefore, starting from v3.0.188, we have temporarily removed the method of installation through source code, and Composer must be used to install the SDK and dependent packages.Feedback